Skip to content

Commit

Permalink
feat: Remove closeMenuExclusionClassName (#385)
Browse files Browse the repository at this point in the history
It breaks grids within modals

So an issue has popped in in step-ag-grid that if you have a grid inside a LuiModal it won't close/save on clicking outside the dialog.
This was due to some hacked in code to stop the grid popups from closing when a LuiModal OK/Cancel appeared, as the dialog would take focus from the grid.
I'm going to remove this code as there's an alternate way of doing this, specifically in your onSave handler you should return a promise if it's going to show a dialog, and resolve the promise when the dialog is approved.
  • Loading branch information
matttdawson authored Aug 21, 2023
1 parent 9714ec7 commit 5bb94be
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/components/GridPopoverHook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export const useGridPopoverHook = <RowType extends GridBaseRow>(props: GridPopov
viewScroll={"auto"}
dontShrinkIfDirectionIsTop={true}
className={props.className}
closeMenuExclusionClassName={"ReactModal__Content"}
>
{saving && ( // This is the overlay that prevents editing when the editor is saving
<div className={"ComponentLoadingWrapper-saveOverlay"} />
Expand Down
7 changes: 2 additions & 5 deletions src/react-menu3/components/ControlledMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export const ControlledMenuFr = (
onItemClick,
onClose,
saveButtonRef,
closeMenuExclusionClassName,
...restProps
}: ControlledMenuProps & { saveButtonRef?: MutableRefObject<HTMLButtonElement | null> },
externalRef: ForwardedRef<HTMLUListElement>,
Expand Down Expand Up @@ -68,10 +67,8 @@ export const ControlledMenuFr = (
);

const isWithinMenu = useCallback(
(target: EventTarget | null) =>
hasParentClass("szh-menu--state-open", target as Node) ||
(closeMenuExclusionClassName && hasParentClass(closeMenuExclusionClassName, target as Node)),
[closeMenuExclusionClassName],
(target: EventTarget | null) => hasParentClass("szh-menu--state-open", target as Node),
[],
);

const handleScreenEventForSave = useCallback(
Expand Down
5 changes: 0 additions & 5 deletions src/react-menu3/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,4 @@ export interface ControlledMenuProps extends RootMenuProps, ExtraMenuProps {
* Event fired when menu is about to close.
*/
onClose?: EventHandler<MenuCloseEvent>;

/**
* When clicking outside the menu to close, anything with this class will not cause a close.
*/
closeMenuExclusionClassName?: string;
}

0 comments on commit 5bb94be

Please sign in to comment.