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

NavigationView BottomMenuItems implementation #1997

Conversation

ad1Dima
Copy link
Contributor

@ad1Dima ad1Dima commented Feb 19, 2020

Fix #375

API spec for this feature can be found here.

Description

I added FooterMenuItems property to NavigationView. My goal also was not to break current behavior of NavigationView.
So i kept both PaneFooter and IsSettingsVisible propertes. However SettingsItem itself now adds to end of FooterItems list if IsSettingsVisible is true

Only braking change is that SettingsItem now have selection when PaneDisplayMode is set to Top. (however there is #1572)
but you can use SelectsOnInvoked property to avoid this

Motivation 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

@ad1Dima
Copy link
Contributor Author

ad1Dima commented Feb 20, 2020

I need help with tests and Accessibility in this PR.

@ranjeshj ranjeshj added area-NavigationView NavView control team-Controls Issue for the Controls team labels Feb 20, 2020
@ranjeshj
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -357,6 +372,7 @@ class NavigationView :
TopNavigationViewDataProvider m_topDataProvider{ this };

winrt::SelectionModel m_selectionModel{};
winrt::SelectionModel m_footerSelectionModel{};
Copy link
Contributor

@ranjeshj ranjeshj Feb 20, 2020

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 ?

Copy link

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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)?

Copy link
Contributor

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 ?

Copy link
Contributor Author

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.

Copy link

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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:
VU9FZ2UQDN
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:
image

Copy link

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
Copy link
Contributor

@ranjeshj ranjeshj Feb 20, 2020

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 ?

Copy link

@YuliKl YuliKl Feb 20, 2020

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).

Copy link
Contributor Author

@ad1Dima ad1Dima Feb 21, 2020

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.

Copy link
Contributor Author

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?

Copy link

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

@ranjeshj
Copy link
Contributor

@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.

@ranjeshj ranjeshj removed the needs-triage Issue needs to be triaged by the area owners label Feb 20, 2020
@ad1Dima
Copy link
Contributor Author

ad1Dima commented Feb 21, 2020

/azp run

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 1997 in repo microsoft/microsoft-ui-xaml

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ojhad
Copy link
Contributor

ojhad commented Mar 3, 2020

Please add some tests exercising the new functionality

Edit: Just noticed your comment above regarding tests. Are you having issues running them locally?

@ad1Dima
Copy link
Contributor Author

ad1Dima commented Mar 4, 2020

Edit: Just noticed your comment above regarding tests. Are you having issues running them locally?

I just didn't find any advices or instructions

@ranjeshj
Copy link
Contributor

ranjeshj commented Mar 4, 2020

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.

@ad1Dima
Copy link
Contributor Author

ad1Dima commented Mar 4, 2020

you can select and run specific tests from that window.

Thx this works. How do you generate reference for VerifyVisualTree tests?

@StephenLPeters
Copy link
Contributor

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.

@ad1Dima
Copy link
Contributor Author

ad1Dima commented Aug 1, 2020

Find out that i didn't work with FooterItemsSource properly. Will fix this also

@anawishnoff
Copy link
Contributor

Just filed a bug for the top mode overflow issue - #3029

Implement FooterItemsSource properly
@ad1Dima
Copy link
Contributor Author

ad1Dima commented Aug 3, 2020

@ojhad Addressed comments and implemented FooterItemsSource. Plz check changes

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

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)
Copy link
Contributor

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.
Copy link
Contributor

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?

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@StephenLPeters
Copy link
Contributor

After nearly 6 months this is going to finally get merged in! Thank you @ad1Dima for being such a trooper!

@StephenLPeters StephenLPeters merged commit 2ec9b1c into microsoft:master Aug 6, 2020
@YuliKl
Copy link

YuliKl commented Aug 6, 2020

Thank you @ad1Dima for all your hard work on this!

@Felix-Dev
Copy link
Contributor

How fitting then that with this merge, WinUI reached another milestone.

1000 closed issues!

image

@ad1Dima
Copy link
Contributor Author

ad1Dima commented Aug 6, 2020

@Felix-Dev how did you get this dark theme?

@Felix-Dev
Copy link
Contributor

Felix-Dev commented Aug 6, 2020

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-NavigationView NavView control team-Controls Issue for the Controls team
Projects
None yet
9 participants