Repository navigation
fix(navigationbar): render UIElement Content on Simple primary commands - #1653
Conversation
Uno's AppBarButton looks up the template part named "Content" and force-sets it to `Icon ?? Content`. The toolkit's own SimpleAppBarButtonStyle (Uno.Toolkit.Simple NavigationBar.xaml) used that name for the icon presenter inside the Viewbox that collapses when no Icon is set, so a UIElement assigned to Content on a NavigationBar primary command was re-parented into the collapsed presenter and never rendered. Strings survived because they can be shown by two presenters. - Rename the icon presenter to IconPresenter (and its visual-state setters); SimpleMainCommandStyle is untouched since it never displays Content. - Add NavigationBarTests.Simple_PrimaryCommands_Render_Icon_And_Content_Variants (red before the fix, green after) covering Icon-only, string Content, UIElement Content and Icon + Content primary commands. - Record the lesson in specs/lessons.md. Same root cause as unoplatform/Uno.Themes#1735 (fixed in Uno.Themes#1736). Fixes #1652 Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
|
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://polite-field-01aa64f0f-1653.eastus2.azurestaticapps.net |
Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://polite-field-01aa64f0f-1653.eastus2.azurestaticapps.net |
|
@Mergifyio backport servicing/10.0 |
✅ Backports have been createdDetails
Cherry-pick of 439331f has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
- specs/lessons.md: drop the committed conflict markers and the main-only entries the cherry-pick dragged in; keep servicing's file plus the one new AppBarButton lesson from #1653. - NavigationBarTests.PrimaryCommands.cs: declare the partial without an access modifier (NavigationBarTests is internal on servicing, public on main; CS0262), and replace Assert.IsNotNull with an explicit null guard since servicing's MSTest does not annotate it for nullable flow (CS8604 under warnings-as-errors). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ds (backport #1653) (#1659) * fix(navigationbar): render UIElement Content on Simple primary commands (#1653) Co-authored-by: Claude Fable 5.1 <[email protected]> (cherry picked from commit 439331f) # Conflicts: # specs/lessons.md * fix(backport): resolve servicing/10.0 conflicts for #1653 - specs/lessons.md: drop the committed conflict markers and the main-only entries the cherry-pick dragged in; keep servicing's file plus the one new AppBarButton lesson from #1653. - NavigationBarTests.PrimaryCommands.cs: declare the partial without an access modifier (NavigationBarTests is internal on servicing, public on main; CS0262), and replace Assert.IsNotNull with an explicit null guard since servicing's MSTest does not annotate it for nullable flow (CS8604 under warnings-as-errors). Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Vatsa Shah <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
GitHub Issue (If applicable): closes #1652
PR Type
What kind of change does this PR introduce?
What is the current behavior?
In the Simple toolkit theme, an
AppBarButtoninNavigationBar.PrimaryCommandswhoseContentis aUIElement(e.g. aGridwrapping aTextBlock) renders an empty slot. StringContentandIconrender fine.Uno's
AppBarButton(AppBarButton.uno.cs,SetupContentUpdate) looks up the template part namedContentand force-sets it toIcon ?? Content. The toolkit's ownSimpleAppBarButtonStyleinsrc/library/Uno.Toolkit.Simple/Styles/Controls/NavigationBar.xamlused that name for the icon presenter inside theViewboxthat collapses whenIconis null. With noIcon, Uno moves the user'sContentinto that collapsed presenter; aUIElementcan only have one visual parent, so it is torn out of the visibleContentPresenter. A string survives because it can be displayed by two presenters at once. Same root cause as unoplatform/Uno.Themes#1735 (fixed in unoplatform/Uno.Themes#1736); the toolkit copy of the style needs the same fix because the NavigationBar resolves its ownSimpleAppBarButtonStyleat parse time.What is the new behavior?
SimpleAppBarButtonStyle: the icon presenter is renamed toIconPresenter(plus its three visual-state setters), with a comment explaining why the part must not be namedContent.SimpleMainCommandStyleis left untouched since that template never displaysContent(it shows the back-arrowPathIconwhenIconis null).NavigationBarTests.Simple_PrimaryCommands_Render_Icon_And_Content_Variants(inNavigationBarTests.PrimaryCommands.cs, partial of the existing class): a Simple-themedNavigationBarwith Icon-only, string-Content, UIElement-Content and Icon + Content primary commands; each marker element must be inside its button, not under a collapsed ancestor, and laid out. Red/fix/green: fails onmain, passes with the fix. The wholeNavigationBar*filter (19 tests) passes on the Simple desktop head in Release.specs/lessons.mdrecords the template-part hijack.Material v2 primary commands are not touched here: they are
BasedOnUno.Themes'MaterialAppBarButtonStyle, so they pick up the fix onceUnoThemesVersionis bumped to a build containing Uno.Themes#1736.PR Checklist
Please check if your PR fulfills the following requirements:
Other information
Two pre-existing local-dev issues noticed while validating, both out of scope:
Debug.AssertinSafeArea.CreateWeakHandler, because static lambdas have a non-nullTarget(the compiler's<>csingleton). Release is unaffected. Similar to what fix(responsive): reconnect a re-parented host instead of tearing down #1647 fixed forResponsiveExtensions.Uno.Toolkit.Simple/Styles/Controls/NavigationBar.xamlonmainas well; formatting it would rewrite the whole file, so this PR keeps the file's existing style.🤖 Generated with Claude Code