Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Commit

Permalink
Revert "fix(Toolbar): close menu when it looses focus (#1688)"
Browse files Browse the repository at this point in the history
This reverts commit 7da5268.
  • Loading branch information
sophieH29 authored Jul 26, 2019
1 parent 7da5268 commit ab35363
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Remove `color` prop from `Dialog` typings @layershifter ([#1702](https://github.com/stardust-ui/react/pull/1702))
- `Loader` uses `Text` component for `label` slot instead of `Box` @layershifter ([#1701](https://github.com/stardust-ui/react/pull/1701))
- Fix test cut off in `Button` component @layershifter ([#1716](https://github.com/stardust-ui/react/pull/1716))
- Close `Toolbar`'s menu when it looses focus @sophieH29 ([#1688](https://github.com/stardust-ui/react/pull/1688))

### Documentation
- Make sidebar categories collapsible @lucivpav ([#1611](https://github.com/stardust-ui/react/pull/1611))
Expand Down
14 changes: 4 additions & 10 deletions packages/react/src/components/Toolbar/ToolbarItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,15 @@ class ToolbarItem extends UIComponent<WithAsProp<ToolbarItemProps>, ToolbarItemS
this.handleClick(event)
},
closeMenuAndFocusTrigger: event => {
if (!this.props.menuOpen) {
return
}

this.trySetMenuOpen(false, event)
if (this.itemRef) {
this.itemRef.current.focus()
}
},
closeMenu: () => {
this.trySetMenuOpen(false, event)
},
doNotNavigateNextToolbarItem: event => {
event.stopPropagation()
},
Expand Down Expand Up @@ -252,7 +253,6 @@ class ToolbarItem extends UIComponent<WithAsProp<ToolbarItemProps>, ToolbarItemS
{submenu}
</>
),
onBlur: this.handleWrapperBlur,
}),
})
}
Expand All @@ -268,12 +268,6 @@ class ToolbarItem extends UIComponent<WithAsProp<ToolbarItemProps>, ToolbarItemS
return <Ref innerRef={this.itemRef}>{renderedItem}</Ref>
}

handleWrapperBlur = e => {
if (this.props.menu && !e.currentTarget.contains(e.relatedTarget)) {
this.trySetMenuOpen(false, e)
}
}

handleBlur = (e: React.SyntheticEvent) => {
this.setState({ isFromKeyboard: false })

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ const toolbarItemBehavior: Accessibility<ToolbarItemBehaviorProps> = props => {
closeMenuAndFocusTrigger: {
keyCombinations: props.menu && props.menuOpen ? [{ keyCode: keyboardKey.Escape }] : null,
},
closeMenu: {
keyCombinations:
props.menu && props.menuOpen ? [{ keyCode: keyboardKey.Tab, shiftKey: true }] : null,
},
doNotNavigateNextToolbarItem: {
keyCombinations:
props.menu && props.menuOpen
Expand Down

0 comments on commit ab35363

Please sign in to comment.