Skip to content

Commit

Permalink
fix: issues with onMouseLeave/onBlur/toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1211 committed Dec 12, 2022
1 parent 438f507 commit 3422a63
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,12 @@ export function usePopupState({
[]
)

const toggle = useCallback(
const toggle = useEvent(
(eventOrAnchorEl?: SyntheticEvent | Element | null) => {
setState((state: CoreState): CoreState => {
if (state.isOpen) close(eventOrAnchorEl)
else open(eventOrAnchorEl)
return state
})
},
[]
if (state.isOpen) close(eventOrAnchorEl)
else open(eventOrAnchorEl)
return state
}
)

const open = useEvent((eventOrAnchorEl?: SyntheticEvent | Element | null) => {
Expand Down

0 comments on commit 3422a63

Please sign in to comment.