-
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
NavView: Expand/Collapse chevron and Overflow button improvements in Top mode #3063
NavView: Expand/Collapse chevron and Overflow button improvements in Top mode #3063
Conversation
Also increased hit target area and FontSize of expand/collapse chevron in top mode to match Left mode values.
…resource in previous commit 2b1145d.
… proposed design.
…ebutton-improvements
IsHitTestVisible="False" /> | ||
</StackPanel> | ||
<Rectangle | ||
x:Name="PointerRectangle" |
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.
PointerRectangle [](start = 36, length = 16)
Maybe name this HitTestRectangle?
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'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....
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.
Ah, I thought this was being newly introduced here.. Where did it live before this?
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.
@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" /> |
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.
4,0,4,4 [](start = 94, length = 7)
I see what you mean about the margin resource now.. I think this could make sense..
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.
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); | ||
} |
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.
Do we need to do this from code behind or can we add this to the template?
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 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\"."); | ||
}); | ||
} |
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 testing that a custom tooltip isn't overwritten would be good too.
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.
Does Content.UpdateLayout() cause NavigationView.ApplyTemplate() to run or do I need to use a new test here?
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.
@ranjeshj do you know off the top of your head?
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.
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.
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.
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>
If I define that style on the app level it is being applied:
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?
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 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.
…pplyTemplate(). Also removed the entry for the "More" string in the ResourceHelper logic and in the default NavigationView resource file.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@Felix-Dev looks like these tests need updating |
@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 |
…ebutton-improvements
@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. |
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. |
@YuliKl Here is how the overflow button could look like with width increased to 48px and border/background brushes matching the NavigationViewItems: Adding reveal border and background wasn't complex at all :) Let me know what you think. |
…round reveal to it.
/azp run |
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}" /> |
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.
@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.
@StephenLPeters Updated some visual verification files. (I left out some of included updated files in the drop archive for now - such as 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 |
@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? |
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 |
@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? |
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. |
@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 🥵 |
@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:
As I did before, I double-checked if these non numbered files (i.e. Seeing as the script output otherwise matches my recent commit, I think we can start a test run here. |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
🎉 Handy links: |
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:
Motivation and Context
Closes #2750.
How Has This Been Tested?
Tested visually and added API test for the Overflow button tooltip.
Screenshots:
(Table showing the expand/collapse glyph with
<x:Double x:Key="NavigationViewItemExpandedGlyphFontSize">20.0</x:Double>
)(The updated 40px hit target area of the expand/collapse chevron inside a NavigationView item).
(Updated hit target area and chevron font size (12px) without highlighted hit target area background)
(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.