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

NavView: Expand/Collapse chevron and Overflow button improvements in Top mode #3063

Conversation

Felix-Dev
Copy link
Contributor

@Felix-Dev Felix-Dev commented Aug 6, 2020

Description

This PR adds a NavigationViewItemExpandedGlyphFontSize resource to allow developers to customize the font size of the expand/collapse chevron.

In addition, it also aligns the expand/collapse chevron in Top mode with the chevron in Left mode by updating its FontSize and increasing its hit target area.

This PR furthermore re-designs the Overflow button in Top mode to match the design proposal given by the design team. Its content has been changed to an ellipsis and the NavigationView.OverflowLabelMode API is no longer relevant for the default control design. The Overflow button now has also received a tooltip matching that of the CommandBar's Overflow button ("See more").

The changes to the Overflow button have been made with maximum backwards compatibility in mind. While the NavigationView.OverflowLabelMode API becomes obsolete with this change, it is being fully retained alongside its internal behavior (i.e. going to its dedicated visual states). The same applies to the existing public Overflow button styles. Both styles have been retained and have been updated to match the new Overflow button design (both styles are now identical). The benefits of this approach are that we are not introducing any style breaking changes as part of this PR. Apps which customized the existing Overflow button styles will still see their custom styles applied - in both the OverflowLabelMode.MoreLabel and OverflowLabelMode.NoLabel configurations.

A couple additional new resources have been added to make customization easier for developers:

  • TopNavigationViewItemContentOnlyContentPresenterMargin
  • TopNavigationViewItemIconOnlyExpandChevronMargin
  • TopNavigationViewItemContentOnlyExpandChevronMargin

Motivation and Context

Closes #2750.

How Has This Been Tested?

Tested visually and added API test for the Overflow button tooltip.

Screenshots:

Left navigation Top navigation
image image

(Table showing the expand/collapse glyph with <x:Double x:Key="NavigationViewItemExpandedGlyphFontSize">20.0</x:Double>)

image
(The updated 40px hit target area of the expand/collapse chevron inside a NavigationView item).

image
(Updated hit target area and chevron font size (12px) without highlighted hit target area background)

image
(The updated Overflow button with tooltip. (The corners of the tooltip are square because I am using the InnerLoop solution here. They will be rounded as expected in the full WinUI product.))

Open Questions

I have opened Implementation-specific questions in a review of the code. Remaining general open questions will be posted in issue #2750.

@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label Aug 6, 2020
IsHitTestVisible="False" />
</StackPanel>
<Rectangle
x:Name="PointerRectangle"
Copy link
Contributor

Choose a reason for hiding this comment

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

PointerRectangle [](start = 36, length = 16)

Maybe name this HitTestRectangle?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm up for the rename but would this be an issue for folks who are grabbing this element, for whatever reason, in their app code and depend on it? Would probably be a very rare situation....

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I thought this was being newly introduced here.. Where did it live before this?

Copy link
Contributor Author

@Felix-Dev Felix-Dev Aug 6, 2020

Choose a reason for hiding this comment

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

@StephenLPeters Sorry, it is getting late here...

The PointerRectangle line comes from the existing NavigationViewOverflowButtonNoLabelStyleWhenPaneOnTop style directly below this style (NavigationViewOverflowButtonStyleWhenPaneOnTop). I just copied that style into this one so they now match.

@@ -1095,16 +1092,18 @@
<VisualState x:Name="IconOnly">
<VisualState.Setters>
<Setter Target="PointerRectangle.Visibility" Value="Visible" />
<Setter Target="LayoutRoot.Width" Value="48" />
<Setter Target="LayoutRoot.MinWidth" Value="48" />
<Setter Target="ContentPresenter.Visibility" Value="Collapsed" />
<Setter Target="SelectionIndicatorGrid.Margin" Value="4,0,4,4" />
Copy link
Contributor

Choose a reason for hiding this comment

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

4,0,4,4 [](start = 94, length = 7)

I see what you mean about the margin resource now.. I think this could make sense..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I am tracking those in #2877 but I can also add the Margin specific resources as part of this PR (while I'm at it).

auto const tooltip = winrt::ToolTip();
tooltip.Content(box_value(ResourceAccessor::GetLocalizedStringResource(SR_NavigationOverflowButtonToolTip)));
winrt::ToolTipService::SetToolTip(topNavOverflowButton, tooltip);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to do this from code behind or can we add this to the template?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have generally seen tooltips in WinUI only being added in code-behind (TabView and existing NavView tooltips, for example) so I am presuming this is the recommended way here.

bool testCondition = toolTipObject is ToolTip toolTip && toolTip.Content.Equals("See more");
Verify.IsTrue(testCondition, "ToolTip text should have been \"See more\".");
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think testing that a custom tooltip isn't overwritten would be good too.

Copy link
Contributor Author

@Felix-Dev Felix-Dev Aug 6, 2020

Choose a reason for hiding this comment

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

Does Content.UpdateLayout() cause NavigationView.ApplyTemplate() to run or do I need to use a new test here?

Copy link
Contributor

Choose a reason for hiding this comment

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

@ranjeshj do you know off the top of your head?

Copy link
Contributor

Choose a reason for hiding this comment

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

ApplyTemplate will be run before running the first layout pass. If you are asking if it will be run again on the next layout (UpdateLayout call), the answer is no.

Copy link
Contributor Author

@Felix-Dev Felix-Dev Aug 7, 2020

Choose a reason for hiding this comment

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

There might be some trouble testing the custom tooltip not being overriden:

Developers today would modify the existing NavigationViewOverflowButtonStyleWhenPaneOnTop style to set a custom tooltip roughly like this:

<Style x:Key="NavigationViewOverflowButtonStyleWhenPaneOnTop" TargetType="Button">
    <Setter Property="ToolTipService.ToolTip" Value="Custom tooltip" />
</Style>

So in order to test that "Custom tooltip" is not being overriden, my thinking was to create a test NavigationView in code-behind containing that style and then check the tooltip content in an interaction test. However, I noticed that setting this style in the NavigationView.Resources scope, or even the Page level scope, does not apply the custom style at all:

<muxc:NavigationView PaneDisplayMode="Top">
    <muxc:NavigationView.Resources>
        <Style x:Key="NavigationViewOverflowButtonStyleWhenPaneOnTop" TargetType="Button">
            <Setter Property="Background" Value="Orange" />
            <Setter Property="Foreground" Value="Green" />
            <Setter Property="ToolTipService.ToolTip" Value="Custom tooltip" />
        </Style>
    </muxc:NavigationView.Resources>
</muxc:NavigationView>

image

If I define that style on the app level it is being applied:
image
image

I would expect here that my custom style defined on the page or control level would be picked up as well (just as how I can override theme resources on the page/control level) as the NavigationView overflow button in Top mode is neither in a Popup nor flyout.

This immediately poses the problem that if I set that style on the app level, then my existing API test to check the default overflow button tooltip will fail as the tooltip content will now be my custom set tooltip.

Thoughts on how to proceed here?

Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like a bug, you should be able to style this from any parent. If this is blocking the custom tooltip test I think its okay to leave that space uncovered until this new bug is resolved.

@StephenLPeters StephenLPeters added area-NavigationView NavView control area-Styling team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Aug 6, 2020
…pplyTemplate(). Also removed the entry for the "More" string in the ResourceHelper logic and in the default NavigationView resource file.
@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@StephenLPeters
Copy link
Contributor

@Felix-Dev looks like these tests need updating

@StephenLPeters
Copy link
Contributor

@Felix-Dev I also just checked in the VisualVerification scripts update #3039 if you could please pull in master and then I can rerun the pipeline so you can update the verification failure

@Felix-Dev
Copy link
Contributor Author

@StephenLPeters Merged with master.

@YuliKl We might just be done here except for whether we should change the width and background/border brushes of the overflow button here to match that of the CommandBar. More info here.

@YuliKl
Copy link

YuliKl commented Aug 11, 2020

@YuliKl We might just be done here except for whether we should change the width and background/border brushes of the overflow button here to match that of the CommandBar. More info here.

Definitely yes to changing the width to 48px. I'm less confident about changing the brushes. If the fix is straight-forward, let's match CommandBar. If the fix is complex, that may not be a good place to apply a lot of effort.

@Felix-Dev
Copy link
Contributor Author

Felix-Dev commented Aug 11, 2020

@YuliKl Here is how the overflow button could look like with width increased to 48px and border/background brushes matching the NavigationViewItems:

navview-overflow-button

Adding reveal border and background wasn't complex at all :) Let me know what you think.

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -402,8 +404,10 @@
<Style x:Key="NavigationViewOverflowButtonStyleWhenPaneOnTop" TargetType="Button">
<Setter Property="Background" Value="{ThemeResource NavigationViewItemBackground}" />
<Setter Property="Foreground" Value="{ThemeResource TopNavigationViewItemForeground}" />
<Setter Property="Height" Value="{StaticResource PaneToggleButtonHeight}" />
<Setter Property="Width" Value="{StaticResource PaneToggleButtonWidth}" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@StephenLPeters @YuliKl Please take a look at this and say if you are fine with this change or not.

The width of the overflow button was set to 40px by the PaneToggleButtonWidth resource. As we decided to increase its width to 48px, changing that resource value would also lead to an increased width for the PaneToggle button which also consumes that resource.

As such, I added a new dedicated resource here to control the width of the overflow button so that the PaneToggle button width will remain unchanged. While this will break customization for developers who used that resource to style the width of the overflow button, I think this is such a minor case here that we should be fine and that the benefits outweigh the possible small inconvenience for developers (if any are caused at all). I also don't know how we would be able to increase the width of that overflow button while keeping the width of the PaneToggle button untouched and not causing a potential customization break....

Once I introduced a dedicated TopNavigationViewOverflowButtonWidth I also created its matching counterpart for the height - TopNavigationViewOverflowButtonHeight.

@Felix-Dev
Copy link
Contributor Author

@StephenLPeters Updated some visual verification files. (I left out some of included updated files in the drop archive for now - such as AppBarToggleButton-7.xml - as I don't really see right now why they are included. After all, I didn't touch the AppBarToggleButton area here, for example, nor does the default style of that button use parts of the NavigationView from what I can tell.)

The visual verification file task determing which files to ship with the drop archive still doesn't seem to work as intended in some cases. For example, I got a whole bunch of

NavigationView*-4.xml
NavigationView*-5.xml
NavigationView*-6.xml

files as part of the drop archive, yet those -4, -5 and -6 files were all identical ( so NavigationViewAuto-4.xml is identical to NavigationViewAuto-5.xml which is identical to NavigationViewAuto-6.xml). In that case, those identical -5 and -6 files shouldn't be included.

@StephenLPeters
Copy link
Contributor

StephenLPeters commented Aug 12, 2020

@StephenLPeters Updated some visual verification files. (I left out some of included updated files in the drop archive for now - such as AppBarToggleButton-7.xml - as I don't really see right now why they are included. After all, I didn't touch the AppBarToggleButton area here, for example, nor does the default style of that button use parts of the NavigationView from what I can tell.)

The visual verification file task determing which files to ship with the drop archive still doesn't seem to work as intended in some cases. For example, I got a whole bunch of

NavigationView*-4.xml
NavigationView*-5.xml
NavigationView*-6.xml

files as part of the drop archive, yet those -4, -5 and -6 files were all identical ( so NavigationViewAuto-4.xml is identical to NavigationViewAuto-5.xml which is identical to NavigationViewAuto-6.xml). In that case, those identical -5 and -6 files shouldn't be included.

@Felix-Dev did you run the GenerateVisualVerificationFiles.ps1 script on the archive drop? instructions were updated here: https://github.com/microsoft/microsoft-ui-xaml/blob/master/docs/developer_guide.md in the Diff & replace section. Also, looking at the Drop, I don't see any Non-NavView visual verification updates

@Felix-Dev
Copy link
Contributor Author

Felix-Dev commented Aug 12, 2020

@StephenLPeters Ah, no, I haven't run the script yet, thanks for pointing it out.

The drop archive contains a single non NavView specific file for me: AppBarToggleButton-7.xml. Weird that it does not show up for you 🤔

Should I revert my previous commit and let the script do its work or would the last commit be fine in case this test run will succeed?

@StephenLPeters
Copy link
Contributor

Hmm, that is very strange, I just double checked here: https://dev.azure.com/ms/microsoft-ui-xaml/_build/results?buildId=100200&view=results and the drop doesn't contain that file

@Felix-Dev
Copy link
Contributor Author

Felix-Dev commented Aug 12, 2020

@StephenLPeters Did you cancel the azure test run here? I was sure you started one some hours ago. If so, what's the status here? Should I revert my commit and run the script instead?

@StephenLPeters
Copy link
Contributor

I never started a lab build. I would prefer we use the script going forward, if you don't mind trying it out here that would be cool.

@Felix-Dev
Copy link
Contributor Author

@StephenLPeters Sure, I will revert the commit and test the script here. And about that lab build I thought you started but actually never did...guess I blame that illusion on the hot weather 🥵

@Felix-Dev
Copy link
Contributor Author

Felix-Dev commented Aug 13, 2020

@StephenLPeters The script output is pretty much the same as the files I uploaded in the recent commit - except that it also lists the non numbered files, so for example:

NavigationViewAuto.xml
NavigationViewAuto-4.xml
NavigationViewAuto-7.xml
NavigationViewAuto-8.xml

As I did before, I double-checked if these non numbered files (i.e. NavigationViewAuto.xml) have actually been updated compared to the existing files - and they are exactly the same, As such, I think the script needs to be slighlty updated to exclude those files.

Seeing as the script output otherwise matches my recent commit, I think we can start a test run here.

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@StephenLPeters StephenLPeters merged commit 2015013 into microsoft:master Aug 17, 2020
@Felix-Dev Felix-Dev deleted the user/Felix-Dev/navview-itemchevron-and-morebutton-improvements branch August 18, 2020 08:19
Kinnara added a commit to Kinnara/ModernWpf that referenced this pull request Aug 18, 2020
@ghost
Copy link

ghost commented Sep 24, 2020

🎉Microsoft.UI.Xaml v2.5.0-prerelease.200923002 has been released which incorporates this pull request.:tada:

Handy links:

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

Successfully merging this pull request may close these issues.

Add a new light weight style to navigation view to customize the item chevron font size.
5 participants