-
Notifications
You must be signed in to change notification settings - Fork 678
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
NavigationView BottomMenuItems implementation #1997
NavigationView BottomMenuItems implementation #1997
Conversation
I need help with tests and Accessibility in this PR. |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
dev/NavigationView/NavigationView.h
Outdated
@@ -357,6 +372,7 @@ class NavigationView : | |||
TopNavigationViewDataProvider m_topDataProvider{ this }; | |||
|
|||
winrt::SelectionModel m_selectionModel{}; | |||
winrt::SelectionModel m_footerSelectionModel{}; |
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.
@YuliKl Are items in the footer considered separately for selection compared to the rest ? Should they be in the same selection model ? I don't think you can have two selections at the same time, so having two selection models might not be correct. Would it be simpler to merge the FooterItems and menu items into a single source for selection model ?
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.
Would it be simpler to merge the FooterItems and menu items into a single source for selection model ?
Yes, I believe so. Ideally all items, whether in the main list or in the footer list, should have at most one item selected at any given time. The items are navigation destinations, and it's not really possible to navigate to more than one destination page at a time.
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.
Ok. I'll move code to single selection model. This should make code simpler
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.
Hm. I looked through code again. SelectionModel
has Source
property. For now this is MenuItemsSource
or MenuItems
for main menu items.
For FooterMenuItems
i had to create collection and dynamically add or remove SettingsItem
to the end of it.
So should i create some array of array as Source
for SelectionModel
or just have two selection models synchronized for keep single selection behavior (just like this code do now)?
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.
@ojhad any ideas. I think a type that takes two collections and exposes itself as one larger collection would be useful here (just exposure, without copying the items from the individual source collections). That way you can feed MenuItems and FooterMenuItems and expose it as a single merged collection. It can be a completely decoupled implementation that can be useful in other scenarios as well. Thoughts ?
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.
Is there a way we are handling a large footer list?
For now, it just grow till it can. And it can take all available space in both left and top mode.
For me, bottomMenuItems is purposed for 2 or 3 items like in Groove or MS Store. And may be it should be app developer responsibility to deal with a lot of items on small screen.
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.
While app developers do need to keep general layout in mind, NavigationView needs to gracefully support scrolling or overflow. On Windows, a user can resize their window at any time, so no one can guarantee that all items will always fit. This is the reason the primary nav list scrolls in left mode and have overflow in top mode. The main and bottom lists may end up visually merged depending on both the number of items and also window size.
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.
For left mode i can try to make single scroll experience for whole pane (with primary nav and footer nav). It will look nice. I did this once.
For top nav i'm not sure what is the best approach. Two overflow menus will look odd
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.
@YuliKl
That's what i did for left menu, is it ok:
But i have no idea what to do with Top menu. For now it can be clipped even without footer items. just if menu footer will be too wide:
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.
Let's not block this PR on getting bottom items to overflow correctly when in Top mode. I think it's fine to create a separate issue to track this limitation and make a note in the docs.
@@ -452,12 +443,15 @@ | |||
VerticalContentAlignment="Stretch" | |||
HorizontalContentAlignment="Stretch" | |||
Grid.Row="7" /> | |||
<Grid | |||
<!-- Left footer menu ItemsRepeater --> | |||
<local:ItemsRepeater |
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.
@YuliKl what should the automation index/size be, is it separate for the footer items or is it part of the main items ?
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.
Right now, the main items are one list and the Settings item is another list with index "1 of 1". I think the right behavior would be to make the bottom items into a list that includes the Settings item. We also want to make sure the keyboard behavior matches this.
So given a list:
- main1
- main2
- bottom1
- bottom2
- settings
Users should be able to Tab between these two lists.
When keyboard focus is on main2, Narrator should announce it as "2 of 2"; pressing Up arrow moves focus to main1; pressing Down arrow moves focus to bottom1; pressing Tab moves focus to bottom1 (unless an item in the bottom list is selected, in which case focus should go to that item).
When keyboard focus is on bottom1, Narrtor should announce it as "1 of 3"; pressing Up arrow moves focus to main2; pressing Down arrow moves focus to bottom2; pressing Tab moves focus to the first focusable item in NavigationView's Header or Content (same behavior as on Settings item today).
When keyboard focus is on settings, Narrator should announce it as "3 of 3"; pressing Up arrow moves focus to bottom2; pressing Down arrow does nothing (same as today); pressing Tab moves focus to a Header or Content item (same as today).
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 right behavior would be to make the bottom items into a list that includes the Settings item.
that's just what i did
(unless an item in the bottom list is selected, in which case focus should go to that item)
this is broken in PR
Narrator should announce it as "3 of 3"
Strange, on Bottom1 Narrator announce "1 of 3", but on Settings "1 of 1". I'll check this.
Everything else working as you described.
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.
@YuliKl How should Home and End work when main2 is selected? When bottom2 is selected?
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.
Home and End move focus within a list. We've said that this work will result in two lists, so
- if focus is on main2 - Home should move focus to main1; End should do nothing
- is focus is on bottom2 - Home should move focus to bottom1; End should move focus to settings
@ojhad Can you please review this change. Please keep an eye out for things that are changing in your upcoming hierarchical navigation view updates, some of which are likely to cause merge conflicts. |
/azp run |
Commenter does not have sufficient privileges for PR 1997 in repo microsoft/microsoft-ui-xaml |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Please add some tests exercising the new functionality Edit: Just noticed your comment above regarding tests. Are you having issues running them locally? |
I just didn't find any advices or instructions |
@ad1Dima There is some documentation here, but it does look like that could be improved. For running tests on your dev machine, make the test explorer visible through the menu Test->TestExplorer. Once you build the muxcontrols.sln file, you will see all the test listed in test explorer. you can select and run specific tests from that window. |
Thx this works. How do you generate reference for VerifyVisualTree tests? |
The originals are checked into the repo, if you need to update them the pipeline produces updated masters and publishes them in the artifacts section, which you can download and replace in your copy of the enlistment. |
Find out that i didn't work with FooterItemsSource properly. Will fix this also |
Just filed a bug for the top mode overflow issue - #3029 |
Implement FooterItemsSource properly
@ojhad Addressed comments and implemented FooterItemsSource. Plz check changes |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@@ -624,6 +709,80 @@ void NavigationView::UpdateItemsRepeaterItemsSource(const winrt::ItemsRepeater& | |||
} | |||
} | |||
|
|||
void NavigationView::UpdateFooterRepeaterItemsSource(bool sourceCollectionReseted, bool sourceCollectionChanged) |
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.
sourceCollectionReseted [](start = 58, length = 23)
sourceCollectionReset
@@ -4290,20 +4528,23 @@ template<typename T> T NavigationView::GetContainerForData(const winrt::IInspect | |||
return nvi; | |||
} | |||
|
|||
if (auto settingsItem = m_settingsItem.get()) | |||
// First conduct a basic top level search in mai menu, which should succeed for a lot of scenarios. |
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.
mai [](start = 49, length = 3)
main?
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
After nearly 6 months this is going to finally get merged in! Thank you @ad1Dima for being such a trooper! |
Thank you @ad1Dima for all your hard work on this! |
@Felix-Dev how did you get this dark theme? |
@ad1Dima It's an addon called Dark Background and Light Text. I linked to a firefox version but it is also available for Chrome and related browsers. And it's fully customizable so you can configure its colors. Generally works pretty good on Github with just 1-2 minor color issues. |
Fix #375
API spec for this feature can be found here.
Description
I added
FooterMenuItems
property toNavigationView
. My goal also was not to break current behavior ofNavigationView
.So i kept both
PaneFooter
andIsSettingsVisible
propertes. HoweverSettingsItem
itself now adds to end ofFooterItems
list ifIsSettingsVisible
is trueOnly braking change is that SettingsItem now have selection when
PaneDisplayMode
is set toTop
. (however there is #1572)but you can use
SelectsOnInvoked
property to avoid thisMotivation and Context
Fix #375
also fixes #1572, #148, #2813, #2814
How Has This Been Tested?
manually on Desktop and Xbox
Checked switching between Top and Left PaneMode
SettingsItem Visibility changing
Dynamically updating of FooterMenuItems
SelectedItem Property and ItemInvoked event