roubachof / Sharpnado.Tabs

Pure MAUI and Xamarin.Forms Tabs, including fixed tabs, scrollable tabs, bottom tabs, badge, segmented control, custom tabs, button tabs, bendable tabs...
MIT License
502 stars 66 forks source link

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

Closed janusw closed 3 weeks ago

janusw commented 1 month ago

Platform (please complete the following information):

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 commented 1 month ago

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

roubachof commented 1 month ago

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

makazeu commented 1 month ago

I can confirm this issue repro in my scenario

janusw commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

should be linked to this: https://github.com/roubachof/Sharpnado.Tabs/issues/84 maybe?

janusw commented 1 month ago

should be linked to this: #84 maybe?

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

https://github.com/roubachof/Sharpnado.Tabs/issues/84#issuecomment-2165192578 mentions a solution concerning OnHandlerChanged. I did some debugging of the TabHostView events and found that:

roubachof commented 1 month ago

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

janusw commented 1 month ago

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?

https://github.com/roubachof/Sharpnado.Tabs/issues/84#issuecomment-2165192578 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 commented 3 weeks ago

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

roubachof commented 3 weeks ago

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

janusw commented 3 weeks ago

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 commented 3 weeks ago

CAn you set UseMauiTapGesture to true on the TabHostView ?

janusw commented 3 weeks ago

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 commented 3 weeks ago

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

https://github.com/user-attachments/assets/0bb263cf-396e-4fa7-bc34-242d0acdd9f3

janusw commented 3 weeks ago

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 commented 3 weeks ago

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 commented 3 weeks ago

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 commented 3 weeks ago

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 commented 3 weeks ago

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 commented 3 weeks ago

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