Skip to content

Commit

Permalink
fix: Fix popover not working in popped out window (#40)
Browse files Browse the repository at this point in the history
* fix: popover not working in popped out window

* feat: renamed mulitEdit to supportsMultiEdit in menu options
  • Loading branch information
matttdawson authored Oct 27, 2022
1 parent dfa648c commit 4dbd343
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/components/GridPopoverHook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ControlledMenu } from "@szhsin/react-menu";
import { GridFormProps } from "./GridCell";
import { hasParentClass } from "@utils/util";
import { GridBaseRow } from "./Grid";
import { isEmpty } from "lodash-es";

export const useGridPopoverHook = <RowType extends GridBaseRow>(
props: GridFormProps<RowType>,
Expand Down Expand Up @@ -84,7 +85,7 @@ export const useGridPopoverHook = <RowType extends GridBaseRow>(
{anchorRef.current && (
<ControlledMenu
state={isOpen ? "open" : "closed"}
portal={true}
portal={isEmpty(document.querySelectorAll(".PopoutWindowContainer"))}
unmountOnClose={true}
anchorRef={anchorRef}
menuClassName={"lui-menu"}
Expand Down
4 changes: 2 additions & 2 deletions src/components/gridForm/GridFormPopoutMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface MenuOption<RowType> {
label: JSX.Element | string | MenuSeparatorType;
action?: (selectedRows: RowType[]) => Promise<boolean>;
disabled?: string | boolean;
multiEdit: boolean;
supportsMultiEdit: boolean;
}

/**
Expand Down Expand Up @@ -65,7 +65,7 @@ export const GridFormPopoutMenu = <RowType extends GridBaseRow>(props: GridFormP
const selectedRowCount = props.selectedRows.length;

const filteredOptions = options?.filter((menuOption) => {
return menuOption.label === MenuSeparator || selectedRowCount === 1 || menuOption.multiEdit;
return menuOption.label === MenuSeparator || selectedRowCount === 1 || menuOption.supportsMultiEdit;
});

const { popoverWrapper } = useGridPopoverHook(props);
Expand Down
6 changes: 3 additions & 3 deletions src/stories/components/GridReadOnly.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
await wait(1500);
return true;
},
multiEdit: false,
supportsMultiEdit: false,
},
{
label: "Multi-edit",
Expand All @@ -107,12 +107,12 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
await wait(1500);
return true;
},
multiEdit: true,
supportsMultiEdit: true,
},
{
label: "Disabled item",
disabled: "Disabled for test",
multiEdit: true,
supportsMultiEdit: true,
},
];
},
Expand Down

0 comments on commit 4dbd343

Please sign in to comment.