-
Notifications
You must be signed in to change notification settings - Fork 705
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 bug where changing the DisplayMode would raise SelectionChanged with SelectedItem as null #1395
Fix bug where changing the DisplayMode would raise SelectionChanged with SelectedItem as null #1395
Conversation
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
The failing tests looks like a legitimate failure. @chingucoding and @licanhua FYI. |
From last build, Look like InteractionTests.NavigationViewTests.EnsureLeftSettingsRetainsFocusAfterOrientationChanges is impacted by this PR. |
I tried reproducing the problem locally. but the test is always succeeding. I have also tried setting the MaxTestedVersion to different Windows versions but the test is still not failing. Am I missing something? |
What is even stranger, the test expects the SettingsSelectionState text box's content to be 'True' but is finding 'False' however when you look at the screen shot at the time of the test it is displaying true.... I've run the test locally and stepped through the test manually and I can't find anything wrong, @licanhua @ojhad do either of you have an idea whats going on? |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@chingucoding , I don't know if it's merging issue. Could you please sync with master first, then create a new PR by merging the code with master to see what will happen? From the screenshot, it should pass sometime but it's not. also I didn't see
|
…t with null as selected item
…hangedIfNotInvokedFromAPI
1a28c90
to
d9d3bcc
Compare
I think I correctly synced my branch with microsoft:master now. Should we try again now? 😅 |
just wait for the test report. |
@chingucoding . I can repro the problem by manual step.
|
I was able to reproduce the issue now with the steps you provided. I think this is something about not correctly animating selection changed. While testing this I also noticed with animations disabled, changing the selected item in DisplayMode = Top does not correctly change the "underline" of the items. I fixed that with the latest commit. And thank you so much @licanhua for finding a way to reproduce this locally! 😅 |
|
||
// Animate to be sure the selected item is visually higlighted! | ||
// See #1395 for additional context | ||
if (oldItem != newItem) |
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.
Don't do it here. Some feature like NavigationRecommendedTransitionDirection, SelectionSuppressed and topnav animation may be broken which is implemented in ChangeSelection.
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.
Hmm I see. So should we set m_shouldRaiseInvokeItemInSelectionChange
to false when before we call ChangeSelection
in OnSelectedItemPropertyChanged
? Or would it be better to move lines 1943/1944 inside CreateAndHookEventsToSettings
?
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.
I don't have good suggestion on it. It's possible that add a flag like 'Hi, I'm switching from topnav to leftnav, please don't raise selection change event for settings'.
Most likely it's not a easy
change because we don't have too much automation on this part and you have to manually verify all kind of scenarios.
I would like @YuliKl to re-evaluate the impact of the bug.
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.
I admit that I'm not quite following the code intricacies within NavigationView and dont' have a good grasp on what's complicating this fix. I do know there's a real problem outlined in #148 that was encountered by a customer (although at this point, I can't locate any record of who originally found this bug).
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.
This seems to be stalling out. @ojhad @licanhua @YuliKl @chingucoding any idea what the next steps are?
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.
I think the least we should do, is to ensure that the selected item that gets passed to the event-handler/event-args is not null.
However not raising the event in that case seems to be quite difficult, as we apparently break animations with that. The question is how common it is for developers to change the orientation of the NavigationView during runtime. If this is an edge case that is not very common, we should maybe not try to prevent the raising of that event. After all, catching that "bug" is something that is definitely achievable.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Hey @chingucoding |
Thanks for the update on that @ojhad. Looking forward to that! I assume it is better to not work on the NavigationView until the refactor is finished? |
I would say contributing bug fixes to the control should still be fine! I decided to defer this fix primarily because of the concerns raised in the discussion above and the difficulty of resolving them. |
@chingucoding This can be revisited now that the refactor is in. It is still an issue, however now there is less complication regarding the selection changes. Let me know if there is anything I can help with! |
@ojhad Thanks for the notice! |
Description
Changed the parameter passed toSetSelectedItemAndExpectItemInvokeWhenSelectionChangedIfNotInvokedFromAPI
fromnullptr
to the settings item instead.Changed code where we update the settings item to set the m_shouldIgnoreNextSelectionChange flag to true, so SelectionChanged ignores that selection change.
Motivation and Context
Fixes #148
How Has This Been Tested?
Added new interaction test, which tests whether the item passed from SelectionChanged event is null or not.
Screenshots (if appropriate):