Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MAUI] [Android] Sharpnado tabs become unusable in combination with MAUI Shell Tabbar #120

Closed
janusw opened this issue Sep 25, 2024 · 21 comments
Labels
bug Something isn't working

Comments

@janusw
Copy link
Collaborator

janusw commented Sep 25, 2024

Platform (please complete the following information):

  • OS: Android
  • Device: Samsung Galaxy S21
  • Sdk version: Android SDK 34
  • MAUI: 8.0.72

Describe the bug
I see strange behavior of a Sharpnado tab bar inside a MAUI application with Shell Tabbar. In certain situations the Sharpnado tabs become unusable and don't react any more.
I'm not actually sure if this is a bug in the MAUI framework itself, or in Sharpnado.Tabs (could be both, I guess).

To Reproduce
Steps to reproduce the behavior:

  1. Download the sample project from https://github.com/janusw/maui-samples/tree/Sharpnado.Tabs_bug/8.0/Navigation/ShellTabBarSample (this is a modified variant of the ShellTabBarSample in my fork of the maui-samples).
  2. Build and run it.
  3. On the shell tab 'One', click the button ("Click me").
  4. A secondary page with a Sharpnado tab bar opens. The tabs have no content in this sample (for simplicity), but switching them works fine.
  5. Switch to the shell tab 'Two'.
  6. Switch back to 'One'.
  7. The Sharpnado tabs are not usable any more. They don't react to tapping.
@janusw
Copy link
Collaborator Author

janusw commented Sep 25, 2024

I verified that the problem occurs also with the latest MAUI version 8.0.90 and down to 8.0.7.

@roubachof
Copy link
Owner

seems like a good first issue for the new contributor of the repo ;)

@makazeu
Copy link

makazeu commented Oct 6, 2024

I can confirm this issue repro in my scenario

@janusw
Copy link
Collaborator Author

janusw commented Oct 8, 2024

I verified that the problem occurs also with the latest MAUI version 8.0.90 and down to 8.0.7.

For completeness: It also happens with .NET 7 (and with 8.0.81, which was released in the meantime).

By now I suspect that it's rather a bug in Sharpnado.Tabs (and not in the MAUI framework).

janusw added a commit to janusw/Sharpnado.Tabs that referenced this issue Oct 8, 2024
@janusw
Copy link
Collaborator Author

janusw commented Oct 8, 2024

I now also set up a reproducer directly in my fork of the Sharpnado.Tabs repo, so that one can debug it directly (together with the lib, and not via the nupkg):

https://github.com/janusw/Sharpnado.Tabs/commits/MauiShellSample/

From the log output and some debugging, I see that TabHostView.OnTabItemTapped is triggered correctly as long as one stays on the same shell tab. After switching shell tabs, it is not triggered any more, but I currently have no idea why.

@roubachof Do you have any ideas how to debug this? Or some suggestions what to try?

@roubachof
Copy link
Owner

should be linked to this: #84 maybe?

@janusw
Copy link
Collaborator Author

janusw commented Oct 8, 2024

should be linked to this: #84 maybe?

Quite probable that this is related. Thanks for the pointer!

#84 (comment) mentions a solution concerning OnHandlerChanged. I did some debugging of the TabHostView events and found that:

  • the Unloaded event is triggered when navigating away from the shell tab that contains the Sharpnado tabs
  • the Loaded and HandlerChanged events are triggered when navigating back to the shell tab that contains the Sharpnado tabs

@roubachof
Copy link
Owner

yup, that's the same for all controls actually.

@janusw
Copy link
Collaborator Author

janusw commented Oct 8, 2024

I tried the following in the OnHandlerChanged method of the TabHostView:

        protected override void OnHandlerChanged()
        {
            base.OnHandlerChanged();
            InternalLogger.Debug(Tag, () => $"HandlerChanged!");
            foreach (var tabItem in Tabs)
            {
                AddTapCommand(tabItem);
            }
        }

However, this does not seem to fix the problem. Any comments?

#84 (comment) says:

Fixed by reregistering the effect in the OnHandlerChanged override.

Am I doing the wrong thing here? Or maybe it is a different issue, after all ...?!?

@roubachof
Copy link
Owner

well it's not linked to #84 since I cannot reproduce the issue with .net8

@roubachof
Copy link
Owner

should be fixed by v3.1.0, please re-open if it doesn't.

@janusw
Copy link
Collaborator Author

janusw commented Oct 18, 2024

Well, yes, I can confirm that v3.1.0 indeed fixes this problem on Android. Thanks! 👍

BUT: It looks like this release completely breaks iOS. The tabs do not react to tapping at all on iOS (observed with my own application, have not checked the sample yet). 😱

@roubachof Can you confirm this? Have you tested on iOS?

@roubachof
Copy link
Owner

CAn you set UseMauiTapGesture to true on the TabHostView ?

@janusw
Copy link
Collaborator Author

janusw commented Oct 18, 2024

CAn you set UseMauiTapGesture to true on the TabHostView ?

Yes, indeed this makes the tab on iOS react again. Maybe it should be the default then (on iOS)? Or are there any downsides?

@roubachof
Copy link
Owner

I just tested on the sample and it's working fine :

Simulator.Screen.Recording.-.iPhone.15.-.2024-10-21.at.11.08.15.mp4

@janusw
Copy link
Collaborator Author

janusw commented Oct 21, 2024

I just tested on the sample and it's working fine :

Yes, it's working in principle (i.e. the tabs react to touching), but it's missing the touch effects on the main toolbar (where you set UseMauiTapGesture). This is the same problem as in my PR #126, which you rejected.

@roubachof
Copy link
Owner

roubachof commented Oct 22, 2024

I don't understand... you said:

It looks like this release completely breaks iOS. The tabs do not react to tapping at all on iOS (observed with my own application, have not checked the sample yet). 😱

But it does react at tapping, you also have the color feedback.
Do you say that you don't have the color feedback on the bottombar ?
If yes your PR didn't add color effect, on the contrary it removed it for all tab items.

@janusw
Copy link
Collaborator Author

janusw commented Oct 22, 2024

I don't understand...

Ok, let's get this straight ....

It looks like this release completely breaks iOS. The tabs do not react to tapping at all on iOS (observed with my own application, have not checked the sample yet). 😱

This statement concerned my own app: The tabs on iOS did not react at all. This is fixed by using UseMauiTapGesture.

But it does react at tapping, you also have the color feedback. Do you say that you don't have the color feedback on the bottombar ?

Now you're talking about the MauiSample app. For this one, the tabs on iOS seems to react, even without UseMauiTapGesture (you added it for some of the TabHostViews there, e.g. on the MainPage, but not all of them).

However, the color effect when tapping seems to be removed by UseMauiTapGesture, e.g. on the MainPage. In your screen recording it is also missing for the main tab bar (but it was there before version 3.1.0).

Btw, I also checked that the tabs are reacting in the MauiShellSample. I'm not sure why it did not work in my case.

If yes your PR didn't add color effect, on the contrary it removed it for all tab items.

Right, I did not mean to say that my PR is better than what you did. 😉

The other way around: Your implementation has the same problem as my naive PR. 😆 (but at least you added a property to switch it).

Would be nice to have one solution that fully works everywhere instead of having workarounds for specific cases.

IIUC, you may need to get rid of the old effects anyway for .NET 9 (in MAUI they we're only kept for compatibility with Xamarin, but it seems like .NET 9 finally removes this compatibility) ...

@roubachof
Copy link
Owner

roubachof commented Oct 22, 2024

I am so lost right now :)
Let's stop talking on a closed issue and please open new issues if something is not working as expected

@janusw
Copy link
Collaborator Author

janusw commented Oct 22, 2024

I am so lost right now :) Let's stop talking on a closed issue and please open new issues if something is not working as expected

Alright 👍 (#130 seems related).

But you can confirm that the touch effect on the sample's main tab bar is missing right now? That's a "regression" in the sample, in a way.

@roubachof
Copy link
Owner

When you are using UseMauiGesture, it uses maui vanilla gesturen which has no touch effect or tap sound

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants