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 menu item command binding (#13848) #14345

Conversation

ooikengsiang
Copy link
Contributor

Description of Change

Fix menu item command binding is removed after navigation. The reference to parent should not be remove when navigating between pages. Page level already handle removal of parent on menu item if the menu item is removed / no longer needed.

Issues Fixed

Fixes #13848

Fix menu item command binding is removed after navigation. The reference to parent should not be remove when navigating between pages. Page level already handle removal of parent on menu item if the menu item is removed / no longer needed.
@ghost ghost added the community ✨ Community Contribution label Apr 1, 2023
@ghost
Copy link

ghost commented Apr 1, 2023

Hey there @ooikengsiang! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@PureWeen PureWeen self-requested a review April 1, 2023 22:20
@jfversluis
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we might need to adjust this test?

Error message
Assert.Null() Failure
Expected: (null)
Actual:   ContentPage { AnchorX = 0.5, AnchorY = 0.5, AutomationId = null, Background = ImmutableBrush { AutomationId = null, BindingContext = { Name = Matthew }, ClassId = null, Color = null, Dispatcher = DispatcherStub { ... }, ... }, BackgroundColor = null, ... }
Stack trace
at Microsoft.Maui.Controls.Core.UnitTests.Menu.MenuTestBase`4.ClearUpdatesParent() in /Users/builder/azdo/_work/1/s/src/Controls/tests/Core.UnitTests/Menu/MenuTestBase.cs:line 111
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)

Remove will trigger collection change and include old item correctly, but clear will not.
@ooikengsiang
Copy link
Contributor Author

Looks like we might need to adjust this test?

Error message
Assert.Null() Failure
Expected: (null)
Actual:   ContentPage { AnchorX = 0.5, AnchorY = 0.5, AutomationId = null, Background = ImmutableBrush { AutomationId = null, BindingContext = { Name = Matthew }, ClassId = null, Color = null, Dispatcher = DispatcherStub { ... }, ... }, BackgroundColor = null, ... }
Stack trace
at Microsoft.Maui.Controls.Core.UnitTests.Menu.MenuTestBase`4.ClearUpdatesParent() in /Users/builder/azdo/_work/1/s/src/Controls/tests/Core.UnitTests/Menu/MenuTestBase.cs:line 111
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)

New commit should fix the unit test, but it also mean calling clear directly on menuitems won't have their parent set to null. This is because on collection changed event doesn't provide removed item in olditems for clear event.

@Eilon Eilon added area-controls-menubar Desktop MenuBarItems legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor labels Jun 20, 2023
@samhouts samhouts added this to the Under Consideration milestone Jul 31, 2023
@samhouts samhouts added the stale Indicates a stale issue/pr and will be closed soon label Sep 11, 2023
Copy link
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one needs to be updated to user the newer AddLogical and RemoveLogical APIs

  • removing the setting of parent to null still makes sense
  • Page should add items as logical children inside collectionchanged
  • can we make Clear work? If we're removing the code that sets the parent to null we'll need to fix clear.

@samhouts samhouts added the s/pr-needs-author-input PR needs an update from the author label Nov 22, 2023
@ghost
Copy link

ghost commented Nov 22, 2023

Hi @ooikengsiang. We have added the "s/pr-needs-author-input" label to this issue, which indicates that we have an open question/action for you before we can take further action. This PRwill be closed automatically in 14 days if we do not hear back from you by then - please feel free to re-open it if you come back to this PR after that time.

@ghost ghost closed this Nov 26, 2023
@ooikengsiang
Copy link
Contributor Author

Sorry, I currently don't have time for this. Since the bot already closed this, I will do it in another branch when I free.
Hey bot, how you count 14 days?

@github-actions github-actions bot locked and limited conversation to collaborators Dec 26, 2023
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
@samhouts samhouts removed this from the Under Consideration milestone Jul 1, 2024
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-menubar Desktop MenuBarItems community ✨ Community Contribution s/pr-needs-author-input PR needs an update from the author stale Indicates a stale issue/pr and will be closed soon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Page changing using menu bar stops command in menu bar from working
5 participants