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

Add padding to the NavigationViewItem to avoid occluding expand/collapse chevron #2342

Conversation

Felix-Dev
Copy link
Contributor

Description

As discussed here this PR adds some right padding to the expand/collapse chevron (its hit area) to ensure there is a 4px space between the chevron and the expanded scrollbar.

The PR also adds an additional right padding to the NavigationViewItem's ContentPresenter to ensure it is visually aligned with the chevron.

Motivation and Context

Closes #2287

How Has This Been Tested?

Tested visually

Screenshots

image

image

@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label Apr 27, 2020
@ojhad
Copy link
Contributor

ojhad commented Apr 28, 2020

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@ojhad ojhad left a comment

Choose a reason for hiding this comment

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

@Felix-Dev could you also upload a screenshot of how this change looks when in a flyout?

@StephenLPeters
Copy link
Contributor

@chigy for FYI, screen shots of what the adjusted margins look like.

@Felix-Dev
Copy link
Contributor Author

Felix-Dev commented Apr 28, 2020

@ojhad
image

Perhaps the added 6px too much to the left 🤔

@chigy
Copy link
Member

chigy commented Apr 28, 2020

@ojhad
image

Perhaps the added 6px too much to the left 🤔

@Felix-Dev , I am not sure what I am looking at. Can you share a screenshot of wider view?

@Felix-Dev
Copy link
Contributor Author

@chigy
image
You are looking at the hierarchical NvaigationView design where the second-level children are shown in a flyout. In this case, "Menu Item 7 (Selectable)" is the child of the NavigationViewItem with the scissors icon (the selected item).

The right padding we decided on in the discussion thread for the chevron is also applied here (even though there is no scrollbar in the flyout).

@chigy
Copy link
Member

chigy commented Apr 28, 2020

@chigy
You are looking at the hierarchical NvaigationView design where the second-level children are shown in a flyout. In this case, "Menu Item 7 (Selectable)" is the child of the NavigationViewItem with the scissors icon (the selected item).

@Felix-Dev , that's what I thought but wanted to make sure. Thanks.

The right padding we decided on in the discussion thread for the chevron is also applied here (even though there is no scrollbar in the flyout).

Why was it applied here? Is it using the same value? I did not expect padding to impact this.

@Felix-Dev
Copy link
Contributor Author

@chigy Yes, the theme resources we updated (e.g. NavigationViewItemExpandChevronMargin) are also applied when the items are shown in a flyout. In other words, the chevron's hit target now has an additional padding of 6px to the right of it. This commit thus moved the chevron 6px further to the left in the flyout, even though there is no scrollbar in this case. As such we are now seeing this "quite large" visual spacing between the chevron and the right border.

I'm currently looking at the code how to best apply the original padding when we are showing the items in a flyout. I would like to do that in a VisualState. My current thinking is - and this might be wrong - to apply our updated paddings only whe the NavigationView is not in the LeftCompact state. When the NavigationView is in LeftCompact only then are we showing the child items in a flyout. When the pane is expanded we show the child items integrated in the NavigationView pane. (This is only talking about Left display mode which is affected by the padding changes, not Top display mode.)

Ideally I would thus have some VisualStates for the NavigationViewItemPresenter I could use here to update the paddings.

@ranjeshj ranjeshj added area-NavigationView NavView control team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Apr 28, 2020
@chigy
Copy link
Member

chigy commented Apr 28, 2020

@Felix-Dev , I found out that the flyout version does indeed display scrollbar when it is long enough so this is unfortunate but looks like by design today until such time we can revisit the scroll bar design.

@Felix-Dev
Copy link
Contributor Author

@chigy I see. Hmm, that's a bit unfortunate then. But I guess it's still better to have the chevron not being party occluded than to not have that unnecessary spacing in the flyout when there's no scrollbar.

@Felix-Dev
Copy link
Contributor Author

Updated the visual tree masters. Although on my local system, the test in question (NavigationViewTests.VerifyVisualTree()) still failed (apparently when trying to verify brush colors?).

Copy link
Contributor

@StephenLPeters StephenLPeters left a comment

Choose a reason for hiding this comment

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

:shipit:

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@StephenLPeters
Copy link
Contributor

@chigy are you signing off on this change?

@ojhad
Copy link
Contributor

ojhad commented May 14, 2020

Moving conversation about cutoff text here. @chigy this is what it looks like when excluding the changes being made in this PR.

image

@chigy
Copy link
Member

chigy commented May 14, 2020

@ojhad , thanks. Unfortunate... It does look more cutoff but doesn't make difference in my signing the change off so will do so.

@Felix-Dev
Copy link
Contributor Author

@ojhad Yes, I'm working on this currently for this PR.

I have also noticed that we have the same issue in PaneDisplayMode::Top when we display menu items with a chevron in the flyout:

image
(See Menu Item 18 in the flyout and its chevron being partly occluded by the expanded scrollbar.) This should probably be addressed as part of this PR as well.

@ojhad
Copy link
Contributor

ojhad commented May 29, 2020

@ojhad Yes, I'm working on this currently for this PR.

Awesome!

This should probably be addressed as part of this PR as well.

Yep, that would make sense. The presenter style for those items is defined under MUX_NavigationViewItemPresenterStyleWhenOnTopPaneOverflow

@StephenLPeters
Copy link
Contributor

@ojhad and @Felix-Dev its been about a week since this got any traction. What are the next steps we need?

@Felix-Dev
Copy link
Contributor Author

Felix-Dev commented Jun 5, 2020

@StephenLPeters I was away over the weekend (we had a long weekend over here) but I'm currently working on finishing this PR. I apologize for any inconvenience this break might have caused.

@StephenLPeters
Copy link
Contributor

@StephenLPeters I was away over the weekend (we had a long weekend over here) but I'm currently working on finishing this PR. I apologize for any inconvenience this break might have caused.

No appologies needed @Felix-Dev I simply wanted to check in on the status :). Thank you so much for helping out with this issue.

* Restored original ContentPresenter margin for top-level items when the pane is in compact mode
* Paddings have been updated to prevent the expand/collapse chevron from being partly occluded by the expanded scrollbar when in Top PaneDisplayMode for items displayed in flyouts (overflow menu and child items)
@Felix-Dev
Copy link
Contributor Author

Felix-Dev commented Jun 5, 2020

As suggested, I added a NavigationViewCompactItemContentPresenterMargin theme resource now to restore the cutoff text to its previous look. See the following images:

image
(Original cutoff margin applied when the NavigationView pane is in compact mode)

image
(Updated NavigationViewItem padding applied to items in flyout when pane is in compact mode)

Padding now has also been added to NavigationViewItems in Top PaneDisplayMode when displayed in flyouts (children flyout and overflow flyout). The expand/collapse chevron now has a 4px spacing between itself and the expanded scrollbar - the same as for the different Left* PaneDisplayModes:

image
(Updated padding displayed in a flyout showing the children for NavViewItem Menu Item 15)

image
(Updated padding displayed in a flyout for the overflow button in Top mode)

This commit also adds another theme resource: TopNavigationViewItemOnOverflowNoIconContentPresenterMargin (This is the ContentPresenter margin used when there is no icon for a NavigationViewItem. It was not yet a theme resource so I added one for it.)

The values for Top PaneDisplayMode theme resources have been modified in such a way to

  • create a spacing of 4px between the expand/collapse chevron and the expanded scrollbar
  • visually align the ContentPresenter with the expand/collapse chevron
  • keep the existing spacing between the ContentPresenter and expand/collapse chevron unchanged

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

@Felix-Dev
Copy link
Contributor Author

Felix-Dev commented Jun 13, 2020

@ojhad @chigy Regarding the cutoff text, with the work done here, we can now also restore the cutoff text look to like it was prior to WinUI 2.4 (with the hierarchical NavView update).

WinUI 2.3 cutoff look:
image
(The NavViewItem content is "Menu Item".)

If we now set our newly introduced theme resource like this:

<Thickness x:Key="NavigationViewCompactItemContentPresenterMargin">0</Thickness>

we get that previous look too:
image

As we now, however, no longer use any right padding, the expanded scrollbar will now occlude the content as much as possible:
image

The request to restore the pre WinUI 2.4 cutoff text in closed compact mode is tracked in issue #2541 and we could work on that as soon as this PR has been merged and you think the original padding (zero padding to the right) should be restored.

@chigy
Copy link
Member

chigy commented Jun 15, 2020

@Felix-Dev , as far as I am aware, it was never intention for us to change the previous behavior with the update we made, so it does make sense to make it so that it behaves the same way it did.

@Felix-Dev
Copy link
Contributor Author

@chigy As soon as this PR is merged, I'll create a PR to restore the previous WinUI 2.3 cutoff text look then.

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Felix-Dev
Copy link
Contributor Author

Seems like we need to start another run: Error C1060: compiler is out of heap space

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ojhad
Copy link
Contributor

ojhad commented Jun 16, 2020

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ojhad ojhad merged commit 8811c96 into microsoft:master Jun 18, 2020
@Felix-Dev Felix-Dev deleted the user/Felix-Dev/navviewitem-padding-6px-with-contentpresenter-alignment branch June 18, 2020 22:07
Kinnara added a commit to Kinnara/ModernWpf that referenced this pull request Jun 19, 2020
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
Development

Successfully merging this pull request may close these issues.

Add a bit of padding to NavigationViewItem to avoid occluding expand/collapse chevron
8 participants