Skip to content

fix AutoDisconnectHandler from triggering on tab changes #34

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

yannickberk
Copy link

This fixes an issue where the SegmentedControl stops working when switching from a tab with a SegmentedControl and later navigating to the tab again.

The AutoDisconnectHandler was triggering when leaving a tab, because only the tabbedPages current element was returned by the GetNavigationTree method. This is problematic as of the time of evaluation the tabbedPage.CurrentElement is already set to the new tab that is navigated to.

GetNavigationTree now returns all contained tabs, to not prematurely disconnect the handlers.

This fixes an issue where the SegmentedControl stops working when switching from a tab with a SegmentedControl and later navigating to the tab again.

The AutoDisconnectHandler was triggering when leaving a tab, because only the tabbedPages current element was returned by the GetNavigationTree method. This is problematic as of the time of evaluation the tabbedPage.CurrentElement is already set to the new tab that is navigated to.

GetNavigationTree now returns all contained tabs, to not prematurely disconnect the handlers.
@thomasgalliker
Copy link
Owner

@yannickberk thanks for the attention in this case. There is also another issue regarding the auto disconnect feature in branch #33. I first gonna merge #33 and then have a look at this one 👍🏻

@yannickberk
Copy link
Author

@thomasgalliker great thank you, i added a branch reproducible-sample-for-tab-issue to my fork, where i changed the sample app to use tabbed pages.
There you can reproduce and confirm the issue with changing tabs back and forth triggering the disconnect handlers and making the SegmentedControl unusable till the page gets recreated.

@thomasgalliker thomasgalliker linked an issue May 16, 2025 that may be closed by this pull request
@thomasgalliker
Copy link
Owner

thomasgalliker commented May 16, 2025

I created another PR #35 and an issue #36.
What currently doesn't work (and it seems very difficult to achieve) is that ALL SegmentedControlHandlers are disconnected automatically when a TabbedPage is disappearing. It looks like a MAUI design flaw that only the currently selected tab page receives the Disconnected event.

Can you @yannickberk check the latest nuget pre-release (1.4.32-pre) and let me know if it solves the TabbedPage problem?
We can continue the discussion in #36.

@thomasgalliker thomasgalliker self-assigned this May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Auto-disconnect doesn't work with TabbedPage
2 participants