fix(iOS): MainCommand style not applied when set via NavigationBar style #1501
+32
−1
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.
GitHub Issue (If applicable): Fixes issue described in problem statement
PR Type
What is the current behavior?
On iOS with Native renderer, when
MainCommandStyleis set on aNavigationBar(typically via a global style), the style is not applied to theMainCommandAppBarButton. The back button fails to render despite no errors.Root cause:
NavigationBarPresenter.SetBindings()only applies the style ifMainCommandalready exists on theCommandBarat binding time. When styles are applied globally orMainCommandis set lazily via data binding, the style binding is never established.What is the new behavior?
MainCommandStyleis applied regardless of whenMainCommandis set. The fix applies theMainCommandStyledirectly inNavigationBar.OnPropertyChangedwhenMainCommandPropertychanges.The solution handles both scenarios:
MainCommandStyleis set first, thenMainCommandis set later → style is applied whenMainCommandchangesMainCommandis set first, thenMainCommandStyleis set later → style is applied whenMainCommandStylechangesPR Checklist
Other information
Changes are minimal and surgical:
NavigationBar.cs: Added 6 lines inOnPropertyChangedmethod to applyMainCommandStylewhenMainCommandPropertychangesNavigationBarTests.cs: Added test verifying style applicationCo-authored-by: @kazo0
Internal Issue (If applicable): N/A
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.