Skip to content

fix(navigationbar): render UIElement Content on Simple primary commands (backport #1653) - #1659

Merged
agneszitte merged 2 commits into
servicing/10.0from
mergify/bp/servicing/10.0/pr-1653
Oct 6, 2026
Merged

agneszitte merged 2 commits into
servicing/10.0from
mergify/bp/servicing/10.0/pr-1653

Conversation

@mergify

@mergify mergify Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

GitHub Issue (If applicable): closes #1652

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

In the Simple toolkit theme, an AppBarButton in NavigationBar.PrimaryCommands whose Content is a UIElement (e.g. a Grid wrapping a TextBlock) renders an empty slot. String Content and Icon render fine.

Uno's AppBarButton (AppBarButton.uno.cs, SetupContentUpdate) looks up the template part named Content and force-sets it to Icon ?? Content. The toolkit's own SimpleAppBarButtonStyle in src/library/Uno.Toolkit.Simple/Styles/Controls/NavigationBar.xaml used that name for the icon presenter inside the Viewbox that collapses when Icon is null. With no Icon, Uno moves the user's Content into that collapsed presenter; a UIElement can only have one visual parent, so it is torn out of the visible ContentPresenter. 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 own SimpleAppBarButtonStyle at parse time.

What is the new behavior?

  • SimpleAppBarButtonStyle: the icon presenter is renamed to IconPresenter (plus its three visual-state setters), with a comment explaining why the part must not be named Content. SimpleMainCommandStyle is left untouched since that template never displays Content (it shows the back-arrow PathIcon when Icon is null).
  • New runtime test NavigationBarTests.Simple_PrimaryCommands_Render_Icon_And_Content_Variants (in NavigationBarTests.PrimaryCommands.cs, partial of the existing class): a Simple-themed NavigationBar with 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 on main, passes with the fix. The whole NavigationBar* filter (19 tests) passes on the Simple desktop head in Release.
  • specs/lessons.md records the template-part hijack.

Material v2 primary commands are not touched here: they are BasedOn Uno.Themes' MaterialAppBarButtonStyle, so they pick up the fix once UnoThemesVersion is bumped to a build containing Uno.Themes#1736.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • Tested the changes where applicable:
    • Skia Desktop (runtime tests, Release)
  • Updated the documentation as needed:
    • No doc change required (no style key or lightweight-styling key changed)
  • Runtime Tests and/or UI Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Contains NO breaking changes
  • Associated with an issue (GitHub or internal)
  • Commits must be following the Conventional Commits specification.

Other information

Two pre-existing local-dev issues noticed while validating, both out of scope:

  • A Debug desktop build of the Simple sample head terminates at startup on the Debug.Assert in SafeArea.CreateWeakHandler, because static lambdas have a non-null Target (the compiler's <>c singleton). Release is unaffected. Similar to what fix(responsive): reconnect a re-parented host instead of tearing down #1647 fixed for ResponsiveExtensions.
  • The XAML Styler passive check fails on Uno.Toolkit.Simple/Styles/Controls/NavigationBar.xaml on main as well; formatting it would rewrite the whole file, so this PR keeps the file's existing style.

🤖 Generated with Claude Code


This is an automatic backport of pull request #1653 done by [Mergify](https://mergify.com).

…ds (#1653)

Co-authored-by: Claude Fable 5.1 <[email protected]>
(cherry picked from commit 439331f)

# Conflicts:
#	specs/lessons.md
@mergify mergify Bot added the conflicts label Sep 30, 2026
@mergify

mergify Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor Author

Cherry-pick of 439331f has failed:

On branch mergify/bp/servicing/10.0/pr-1653
Your branch is up to date with 'origin/servicing/10.0'.

You are currently cherry-picking commit 439331f.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	new file:   src/Uno.Toolkit.RuntimeTests/Tests/NavigationBarTests.PrimaryCommands.cs
	modified:   src/library/Uno.Toolkit.Simple/Styles/Controls/NavigationBar.xaml

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   specs/lessons.md

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

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 236521 has failed on Uno Toolkit - CI.

- 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]>
@vatsashah45
vatsashah45 requested a review from agneszitte October 5, 2026 13:37
@agneszitte
agneszitte merged commit 3e385b5 into servicing/10.0 Oct 6, 2026
20 checks passed
@agneszitte
agneszitte deleted the mergify/bp/servicing/10.0/pr-1653 branch October 6, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants