Skip to content

Commit

Permalink
Hide menus when they lose focus
Browse files Browse the repository at this point in the history
  • Loading branch information
gnapse committed Mar 7, 2024
1 parent cca366b commit 354f53f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Reactist follows [semantic versioning](https://semver.org/) and doesn't introduc
# v24.1.1-beta

- [Fix] It was possible to leave a tooltip in a state in which it remained visible all the time. This release fixes the issue.
- [Fix] Auto-close menus when they lose focus to elements other than their own content or their sub-menus.

# v24.1.0-beta

Expand Down
6 changes: 6 additions & 0 deletions src/menu/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ const MenuList = polymorphicComponent<'div', MenuListProps>(function MenuList(
className={classNames('reactist_menulist', exceptionallySetClassName)}
getAnchorRect={getAnchorRect ?? undefined}
modal={modal}
onBlur={(event) => {
if (!event.relatedTarget) return
if (event.currentTarget.contains(event.relatedTarget)) return
if (event.relatedTarget?.closest('[role^="menu"]')) return
menuStore.hide()
}}
/>
</Portal>
) : null
Expand Down

0 comments on commit 354f53f

Please sign in to comment.