Skip to content

Commit

Permalink
fix(@clayui/shared): remove suppression from elements before focus
Browse files Browse the repository at this point in the history
  • Loading branch information
matuzalemsteles committed Aug 16, 2024
1 parent 9a99238 commit c9a9e83
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
1 change: 0 additions & 1 deletion packages/clay-drop-down/src/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ const Menu = React.forwardRef<HTMLDivElement, IProps>(

return (
<Overlay
inert
isCloseOnInteractOutside={closeOnClickOutside}
isKeyboardDismiss
isModal={lock}
Expand Down
21 changes: 13 additions & 8 deletions packages/clay-shared/src/Overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ export function Overlay({
onHide('blur');
},
onInteractStart: (event) => {
if (unsuppressCallbackRef.current) {
unsuppressCallbackRef.current();
unsuppressCallbackRef.current = null;
}

if (overlayStack[overlayStack.length - 1] === menuRef && isModal) {
event.stopPropagation();
event.preventDefault();
Expand Down Expand Up @@ -152,16 +157,16 @@ export function Overlay({
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert
if ((isModal || inert) && supportsInert()) {
unsuppressCallbackRef.current = suppressOthers(elements);

return () => {
if (unsuppressCallbackRef.current) {
unsuppressCallbackRef.current();
}
unsuppressCallbackRef.current = null;
};
} else {
return hideOthers(elements);
unsuppressCallbackRef.current = hideOthers(elements);
}

return () => {
if (unsuppressCallbackRef.current) {
unsuppressCallbackRef.current();
}
unsuppressCallbackRef.current = null;
};
}
}, [isModal, inert, isOpen]);

Expand Down

0 comments on commit c9a9e83

Please sign in to comment.