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

Fix Android flyout button (burger) visibility not reevaluated when orientation changes #24469

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

Conversation

guyvaio
Copy link

@guyvaio guyvaio commented Aug 27, 2024

The condition to show the flyout button (burger) or not is set in method ShouldShowToolbarButton of the FlyoutPage. In Android, this method is not hit when orientation changes. This method is only called once during initialization.

This modification triggers the update of this button when orientation changes.

#24468

The condition to show the flyout button (burger) or not is set in method ShouldShowToolbarButton of the FlyoutPage.
In Android, this method is not hit when orientation changes. This method is only called once during initialization.

This modification triggers the update of this button when orientation changes.

dotnet#24468
@guyvaio guyvaio requested a review from a team as a code owner August 27, 2024 13:18
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Aug 27, 2024
@samhouts samhouts added the area-navigation NavigationPage label Aug 27, 2024
@guyvaio guyvaio changed the title Update NavigationPageToolbar.cs Fix Android flyout button (burger) visibility not reevaluated when orientation changes Aug 30, 2024
@rmarinho
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@Brosten
Copy link

Brosten commented Sep 5, 2024

+1

@guyvaio
Copy link
Author

guyvaio commented Sep 6, 2024

Temporary fix https://gist.github.com/guyvaio/5ca11a6aa373c1fe486cc9e25137aeec
Hope this helps others.

@dhindrik
Copy link
Contributor

dhindrik commented Sep 9, 2024

We have tried the temporary fix, but it doesn't fix the problem for us.

@guyvaio
Copy link
Author

guyvaio commented Sep 9, 2024

We have tried the temporary fix, but it doesn't fix the problem for us.

Line 212 should be hit when tablet is rotated.
toolbarUpdateUpdateBackButtonMethod?.Invoke(toolbar, null);

@dhindrik
Copy link
Contributor

dhindrik commented Sep 9, 2024

We have tried the temporary fix, but it doesn't fix the problem for us.

Line 212 should be hit when tablet is rotated. toolbarUpdateUpdateBackButtonMethod?.Invoke(toolbar, null);

That line is hit.

@guyvaio
Copy link
Author

guyvaio commented Sep 9, 2024

We have tried the temporary fix, but it doesn't fix the problem for us.

Line 212 should be hit when tablet is rotated. toolbarUpdateUpdateBackButtonMethod?.Invoke(toolbar, null);

That line is hit.

The method invoked by reflection is visible at line 158 of https://github.com/dotnet/maui/blob/main/src/Controls/src/Core/NavigationPage/NavigationPageToolbar.cs
Please check the conditions to see if you hit lines 171 and 173 (_drawerToggleVisible = ...)

Have also a check on the ShouldShowToolbarButton method (if not overriden in your code) : line 181 of https://github.com/dotnet/maui/blob/main/src/Controls/src/Core/FlyoutPage/FlyoutPage.cs

@dhindrik
Copy link
Contributor

We did a simple fix for this. Maybe not the nicest and cleanest solution, but it make it work and the menu button is always visible when it should.

 Flyout = new ContentPage();
 Flyout.SizeChanged += Flyout_SizeChanged;

public override bool ShouldShowToolbarButton()
{
#if ANDROID
      return true;
#else
      return base.ShouldShowToolbarButton();
#endif
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-navigation NavigationPage community ✨ Community Contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants