Repository navigation
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[net11.0] Expose toolbar drawer-toggle visibility on IToolbar #37863
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
Uh oh!
There was an error while loading. Please reload this page.
[net11.0] Expose toolbar drawer-toggle visibility on IToolbar #37863
Changes from all commits
b92f37f24ae20f05f411f53b90739dc0b20b95129c00405feFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[moderate] Handler Mapper and Property Patterns / Regression Prevention — This notification re-introduces a handler-driven navigation-icon write on exactly the transition that the
#if ANDROIDbranch a few lines above (_backButtonVisible = GetBackButtonVisible();, assigned deliberately withoutSetPropertyso no handler update is pushed) was written to leave alone. On non-Windows,drawerToggleVisibleis... && !anyPagesPushed.Value, so it flips on the same first-push / last-pop where_backButtonVisibleflips. With the new#if ANDROID || TIZENmapping inToolbar.Mapper.cs,NotifyPropertyChanged(nameof(DrawerToggleVisible))now routes toMapDrawerToggleVisible→AToolbar.UpdateBackButton(toolbar), which reads the already-updatedBackButtonVisibleand hard-setsnativeToolbar.NavigationIconplusDrawerArrowDrawable.Progress = 1(or= 0). That is the platform icon write the Android branch avoids. If the suppression is no longer needed, the#if ANDROIDspecial case should be removed in the same change; if it is still needed, this notification should be gated so it does not fire on the push/pop transition. Neither option is exercised by the added tests — no test drives a realToolbarHandleron Android.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[major] Handler Mapper and Property Patterns / Regression Prevention — This notification re-introduces a handler-driven navigation-icon write on exactly the transition that the
#if ANDROIDbranch a few lines above deliberately suppresses. In the!_userChangedpath Android assigns_backButtonVisible = GetBackButtonVisible();directly (noSetProperty, so noHandler.UpdateValue), becauseToolbarHandler.Androidwires the navigation icon throughNavigationUI.SetupWithNavController(...)/AppBarConfiguration.SetOpenableLayout(_drawerLayout)and animates the hamburger↔arrow via the NavController destination change.Concrete scenario (Android,
FlyoutPagewhose Detail is aNavigationPage, flyout behaviorFlyout): pushing the second page makesanyPagesPushedtrue, sodrawerToggleVisiblegoestrue -> false,drawerToggleVisibleChangedis true, and this line firesHandler.UpdateValue("DrawerToggleVisible"). With the new#if ANDROID || TIZENmapping inToolbar.Mapper.csthat reachesToolbar.MapDrawerToggleVisible->AToolbar.UpdateBackButton(toolbar), which readstoolbar.BackButtonVisible(already updated totrueby the untracked field assignment) and immediately setsiconDrawable.Progress = 1on the sharedDrawerArrowDrawable. That is the same write the Android branch was written to avoid, so the drawer→arrow morph is snapped to its end state instead of being animated by the navigation transition. The reverse pop-to-root case snapsProgress = 0.Suggest scoping the new notification so Android keeps its animation-owned path — e.g.
#if !ANDROIDaround the notification when the untracked_backButtonVisibleassignment was taken, or route the drawer-only change through a mapper that does not touchDrawerArrowDrawable.Progress. Whatever is chosen, please add an Android device/UI regression test for FlyoutPage+NavigationPage push/pop, since no test in this PR covers it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[moderate] Logic and Correctness / Null Safety — The rewritten
elsebranch changes the no-navigation-icon case from a handler-free assignment into a call that unconditionally dereferences the handler. Previously this branch waselse if (toolbar.TitleIcon == null) { platformToolbar.Icon = null; }and never touchedtoolbar.Handler.UpdateTitleIcon(toolbar, generation)begins with_ = toolbar?.Handler?.MauiContext ?? throw new ArgumentNullException(...), soUpdateBackButtonnow throws whenever it runs before the toolbar handler/MauiContextis available. Concrete path:ShellViewsubscribesElement.Toolbar.PropertyChangedin its constructor andUpdateFlyoutBehaviorcallsRefreshNavigationSlot()→_toolbar?.UpdateBackButton(Element!.Toolbar); both can fire on a Shell whoseToolbar.Handleris not yet connected, where the old code simply cleared the icon.Second effect on the same line: when
TitleIconis non-null the old code intentionally did nothing (the icon was already installed byUpdateTitleIcon). Now everyUpdateBackButtoninvocation — including the newly-registeredMapDrawerToggleVisible,MapBackButtonVisible, and eachRefreshNavigationSlot()— restarts an asyncsource.LoadImage(...)and allocates a freshTImagethat replacesplatformToolbar.Iconwithout disposing the previous NUI view. A Tizen page with aTitleIcontherefore re-decodes its toolbar icon on every unrelated navigation-slot update.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[major] Null Safety / Logic and Correctness — The rewritten
elsebranch turns a handler-free assignment into a call that unconditionally dereferences the handler. Previously this branch waselse if (toolbar.TitleIcon == null) { platformToolbar.Icon = null; }and never touchedtoolbar.Handler.UpdateTitleIcon(toolbar, generation)starts with_ = toolbar?.Handler?.MauiContext ?? throw new ArgumentNullException(...), which now runs before thesource == null || source.IsEmptyearly-out, soUpdateBackButtonthrows whenever the toolbar has no connected handler/MauiContext.Concrete scenario:
ShellView.RefreshNavigationSlot()(this PR's rename) calls_toolbar?.UpdateBackButton(Element!.Toolbar)fromUpdateFlyoutBehavior(...)and from thePropertyChangedlistener.Element.Toolbaris the Shell-ownedShellToolbar, whoseHandler/MauiContextis not guaranteed to be set at those points (early Shell setup, or after the toolbar handler is disconnected on teardown) — previously that path was safe because the no-icon case never read the handler. Suggest moving theMauiContextguard below thesource == null || source.IsEmptyearly-out, or guarding theelsebranch with atoolbar.Handler?.MauiContext is not nullcheck and clearingplatformToolbar.Iconotherwise.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[major] Regression Prevention and Test Coverage — This registration is the actual fix (before it,
Handler?.UpdateValue("DrawerToggleVisible")was a no-op because no mapping existed), yet nothing in the PR exercises it. It is compiled only under#if ANDROID || TIZEN, whileControls.Core.UnitTestsbuilds fornetonly, soMapDrawerToggleVisibleand thisReplaceMappingcall are never executed by any added test. Every new test attaches a hand-writtenExternalToolbarBackendHandlerwith its own mapper, which proves thatDrawerToggleVisibleraises a handler update but not that the shipped Android/Tizen mapping exists, is keyed correctly, or produces the correct native icon. The reported symptom (flyout/hamburger affordance not appearing or not clearing in the toolbar's navigation slot) has no device or UI regression test, so the exact scenario from the issue is not covered and a future removal of this line would not fail any test.Separately,
ReplaceMapping(rather thanAppendToMapping/ModifyMapping) silently discards anyDrawerToggleVisiblemapping a consumer registered beforeToolbar.RemapForControls()runs.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[major] Regression Prevention and Test Coverage — This registration is the actual behavioral fix: before it,
Handler?.UpdateValue("DrawerToggleVisible")was a no-op becauseToolbarHandler.Mapperhad no entry for that key (Core's mapper only definesTitle). Nothing in the PR exercises it. The line is compiled only under#if ANDROID || TIZEN, whileControls.Core.UnitTestsbuildsnetonly, so neitherMapDrawerToggleVisiblenor the registration is reachable fromToolbarDrawerToggleTests. The added tests assertNotifyPropertyChangedfires and that a stubElementHandler.UpdateValuerecords the key, which passes with or without this registration.Also note the semantics differ from the interface doc: because the mapping is Android/Tizen-only, a change does not raise a platform update on iOS/MacCatalyst/Windows. Consider a device test under
Controls.DeviceTests(Android) that asserts the platformAToolbar.NavigationIcon/DrawerArrowDrawable.Progressafter a drawer-only transition — that is the only level at which this line is currently observable.Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.