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

Make consistency behaviour when clicking on a unselected item or clicking on a selected item #589

Merged
merged 1 commit into from
Apr 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions dev/NavigationView/NavigationView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1324,10 +1324,7 @@ void NavigationView::ChangeSelection(const winrt::IInspectable& prevItem, const

AnimateSelectionChanged(prevItem, nextActualItem);

if (IsPaneOpen() && DisplayMode() != winrt::NavigationViewDisplayMode::Expanded)
{
ClosePane();
}
ClosePaneIfNeccessaryAfterItemIsClicked();
}
}
}
Expand All @@ -1348,6 +1345,8 @@ void NavigationView::OnItemClick(const winrt::IInspectable& /*sender*/, const wi
if (!m_shouldIgnoreNextSelectionChange && DoesSelectedItemContainContent(clickedItem, itemContainer) && !IsSelectionSuppressed(selectedItem))
{
RaiseItemInvoked(selectedItem, false /*isSettings*/, itemContainer);

ClosePaneIfNeccessaryAfterItemIsClicked();
}
}

Expand Down Expand Up @@ -3228,6 +3227,14 @@ void NavigationView::OnTitleBarIsVisibleChanged(const winrt::CoreApplicationView
UpdateTitleBarPadding();
}

void NavigationView::ClosePaneIfNeccessaryAfterItemIsClicked()
{
if (IsPaneOpen() && DisplayMode() != winrt::NavigationViewDisplayMode::Expanded)
{
ClosePane();
}
}

bool NavigationView::ShouldIgnoreMeasureOverride()
{
return m_shouldIgnoreNextMeasureOverride || m_shouldIgnoreOverflowItemSelectionChange || m_shouldIgnoreNextSelectionChange;
Expand Down
1 change: 1 addition & 0 deletions dev/NavigationView/NavigationView.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class NavigationView :
void CoerceToGreaterThanZero(double& value);

private:
void ClosePaneIfNeccessaryAfterItemIsClicked();
bool ShouldIgnoreMeasureOverride();
bool NeedTopPaddingForRS5OrHigher(winrt::CoreApplicationViewTitleBar const& coreTitleBar);
void OnAccessKeyInvoked(winrt::IInspectable const& sender, winrt::AccessKeyInvokedEventArgs const& args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,47 @@ public void DisplayModeTest()
}
}

[TestMethod]
[TestProperty("NavViewTestSuite", "A")]
public void VerifyPaneIsClosedWhenClickingOnSelectedItem()
{
using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "NavigationView Test" }))
{
var displayModeTextBox = new TextBlock(FindElement.ByName("DisplayModeTextBox"));
var panelDisplayModeComboBox = new ComboBox(FindElement.ByName("PaneDisplayModeCombobox"));

Log.Comment("Test PaneDisplayMode=LeftMinimal");
panelDisplayModeComboBox.SelectItemByName("LeftMinimal");
Wait.ForIdle();

WaitAndAssertPaneStatus(PaneOpenStatus.Closed);

Log.Comment("Click on ToggleButton");
Button navButton = new Button(FindElement.ById("TogglePaneButton"));
navButton.Invoke();
Wait.ForIdle();

WaitAndAssertPaneStatus(PaneOpenStatus.Opened);

Log.Comment("Select Apps");
UIObject appsItem = FindElement.ByName("Apps");
appsItem.Click();
Wait.ForIdle();

WaitAndAssertPaneStatus(PaneOpenStatus.Closed);

Log.Comment("Click on ToggleButton");
navButton.Invoke();
Wait.ForIdle();

Log.Comment("Click on SelectedItem Apps");
appsItem.Click();
Wait.ForIdle();

WaitAndAssertPaneStatus(PaneOpenStatus.Closed);
}
}

[TestMethod]
[TestProperty("NavViewTestSuite", "A")]
public void PaneDisplayModeLeftLeftCompactLeftMinimalTest()
Expand Down