Skip to content

Commit

Permalink
fix(@clayui/drop-down): fixes bug with chrome blocking element focus …
Browse files Browse the repository at this point in the history
…when clicking outside the menu
  • Loading branch information
matuzalemsteles committed Aug 14, 2024
1 parent 3b6a49e commit 9a99238
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/clay-drop-down/src/DropDown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ function ClayDropDown<T>({
navigationProps.onKeyDown(event);
}}
ref={menuElementRef}
suppress={[triggerElementRef, menuElementRef]}
triggerRef={triggerElementRef}
width={menuWidth}
>
Expand Down
1 change: 1 addition & 0 deletions packages/clay-drop-down/src/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ const Menu = React.forwardRef<HTMLDivElement, IProps>(

return (
<Overlay
inert
isCloseOnInteractOutside={closeOnClickOutside}
isKeyboardDismiss
isModal={lock}
Expand Down
6 changes: 4 additions & 2 deletions packages/clay-shared/src/Overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type {Undo} from 'aria-hidden';

type Props = {
children: React.ReactElement;
inert?: boolean;
isCloseOnInteractOutside?: boolean;
isKeyboardDismiss?: boolean;
isModal?: boolean;
Expand All @@ -35,6 +36,7 @@ const overlayStack: Array<React.RefObject<Element>> = [];
*/
export function Overlay({
children,
inert,
isCloseOnInteractOutside = false,
isKeyboardDismiss = false,
isModal = false,
Expand Down Expand Up @@ -148,7 +150,7 @@ export function Overlay({
// Inert is a new native feature to better handle DOM arias that are not
// assertive to a SR or that should ignore any user interaction.
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert
if (isModal && supportsInert()) {
if ((isModal || inert) && supportsInert()) {
unsuppressCallbackRef.current = suppressOthers(elements);

return () => {
Expand All @@ -161,7 +163,7 @@ export function Overlay({
return hideOthers(elements);
}
}
}, [isModal, isOpen]);
}, [isModal, inert, isOpen]);

return (
<ClayPortal className={menuClassName} subPortalRef={portalRef}>
Expand Down

0 comments on commit 9a99238

Please sign in to comment.