Skip to content

Commit

Permalink
fix: move the enabled check to unmounting
Browse files Browse the repository at this point in the history
  • Loading branch information
milhamm committed Apr 26, 2023
1 parent 547d795 commit fc594eb
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,10 @@ function useRestoreFocus({ ownerDocument }: { ownerDocument: Document | null },
// Restore the focus to the previous element when the component is unmounted
let trulyUnmounted = useRef(false)
useEffect(() => {
if (!enabled) return

trulyUnmounted.current = false

return () => {
if (!enabled) return
trulyUnmounted.current = true
microTask(() => {
if (!trulyUnmounted.current) return
Expand Down

0 comments on commit fc594eb

Please sign in to comment.