Skip to content

Commit

Permalink
only return focus to the trigger if the focus trap is already set
Browse files Browse the repository at this point in the history
  • Loading branch information
bmcmahen committed Aug 1, 2019
1 parent e017940 commit f750c2f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Hooks/use-focus-trap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ export function useFocusElement(
trap.deactivate();
}

if (showing) focusElement();
else focusTrigger();
if (showing) {
focusElement();
return () => {
focusTrigger();
};
}
}, [showing]);
}

0 comments on commit f750c2f

Please sign in to comment.