Skip to content

Commit

Permalink
chore: custom dialog zIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
creed-victor committed Jun 20, 2023
1 parent d8bd0d1 commit cad0a8b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/hot-wombats-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sovryn/ui': patch
---

chore: custom dialog zIndex
6 changes: 4 additions & 2 deletions packages/ui/src/2_molecules/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type DialogProps = {
initialFocusRef?: React.RefObject<HTMLElement>;
disableFocusTrap?: boolean;
buttonCloseText?: string;
initialZIndex?: number;
};

export const Dialog: IDialogFunctionComponent<DialogProps> = ({
Expand All @@ -47,6 +48,7 @@ export const Dialog: IDialogFunctionComponent<DialogProps> = ({
initialFocusRef,
disableFocusTrap,
buttonCloseText,
initialZIndex = 100,
}) => {
const ref = useRef<HTMLDivElement>(null);

Expand All @@ -61,9 +63,9 @@ export const Dialog: IDialogFunctionComponent<DialogProps> = ({
// make sure that multiple dialogs opened showing up in correct order.
if (isOpen) {
Dialog.index++;
setZIndex(100 + Dialog.index);
setZIndex(initialZIndex + Dialog.index);
}
}, [isOpen]);
}, [isOpen, initialZIndex]);

useEffect(() => {
const handleEscape = (event: KeyboardEvent) => {
Expand Down

0 comments on commit cad0a8b

Please sign in to comment.