Skip to content

Commit

Permalink
[Navigation] Fix navigation hide on key press (#2607)
Browse files Browse the repository at this point in the history
* Fix nav hide bug

* Update src/components/Frame/tests/Frame.test.tsx

Co-Authored-By: Andrew Musgrave <andrew.musgrave@shopify.com>

* Update src/components/Frame/tests/Frame.test.tsx

Co-Authored-By: Andrew Musgrave <andrew.musgrave@shopify.com>

Co-authored-by: Andrew Musgrave <andrew.musgrave@shopify.com>
  • Loading branch information
kyledurand and AndrewMusgrave committed Jan 14, 2020
1 parent 2d7e065 commit 0d43805
Show file tree
Hide file tree
Showing 3 changed files with 205 additions and 156 deletions.
1 change: 1 addition & 0 deletions UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

### Bug fixes

- Fixed a bug where `Navigation` calls `onNavigationDismiss` on large screens when focused and the escape key is pressed ([#2607](https://github.com/Shopify/polaris-react/pull/2607))
- Fixed issue with `Filters` component displaying an undesired margin top and bottom on the button element on Safari ([#2292](https://github.com/Shopify/polaris-react/pull/2292))
- Doesn't render `MenuActions` if no actions are passed to an `actionGroups` item inside `Page` ([#2266](https://github.com/Shopify/polaris-react/pull/2266))
- Fixed `PositionedOverlay` incorrectly calculating `Topbar.UserMenu` `Popover` width ([#1692](https://github.com/Shopify/polaris-react/pull/1692))
Expand Down
9 changes: 8 additions & 1 deletion src/components/Frame/Frame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,15 @@ class Frame extends React.PureComponent<CombinedProps, State> {

private handleNavKeydown = (event: React.KeyboardEvent<HTMLElement>) => {
const {key} = event;
const {
polaris: {
mediaQuery: {isNavigationCollapsed},
},
showMobileNavigation,
} = this.props;

if (key === 'Escape') {
const mobileNavShowing = isNavigationCollapsed && showMobileNavigation;
if (mobileNavShowing && key === 'Escape') {
this.handleNavigationDismiss();
}
};
Expand Down
Loading

0 comments on commit 0d43805

Please sign in to comment.