Skip to content

Commit

Permalink
fix(core): reactions menu open issue (#6765)
Browse files Browse the repository at this point in the history
  • Loading branch information
hermanwikner authored May 27, 2024
1 parent 10e1bc3 commit 3f52b83
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,27 @@ export function CommentReactionsMenuButton(props: CommentReactionsMenuButtonProp

setOpen(false)
onMenuClose?.()
}, [open, onMenuClose])

const handleCloseAndFocus = useCallback(() => {
if (!open) return

handleClose()
buttonElement?.focus()
}, [buttonElement, onMenuClose, open])
}, [buttonElement, handleClose, open])

const handleKeyDown = useCallback(
(event: React.KeyboardEvent<HTMLDivElement>) => {
const {key, shiftKey} = event

if ((shiftKey && key === 'Tab') || key === 'Escape' || key === 'Tab') {
handleClose()
handleCloseAndFocus()
}
},
[handleClose],
[handleCloseAndFocus],
)

useClickOutside(handleClick, [popoverElement, buttonElement])
useClickOutside(handleClose, [popoverElement, buttonElement])

const handleSelect = useCallback(
(option: CommentReactionOption) => {
Expand Down

0 comments on commit 3f52b83

Please sign in to comment.