Skip to content

Commit 23fa9b0

Browse files
authored
fix(modals): always pass environment to useModal hook (#2059)
1 parent 7f160cb commit 23fa9b0

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

packages/modals/src/elements/Modal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ export const ModalComponent = forwardRef<HTMLDivElement, IModalProps>(
8181
onClose,
8282
modalRef,
8383
focusOnMount,
84-
restoreFocus
84+
restoreFocus,
85+
environment
8586
});
8687

8788
useEffect(() => {

packages/modals/src/elements/TooltipDialog/TooltipDialog.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ import { Body } from './Body';
3131
import { Close } from './Close';
3232
import { Footer } from './Footer';
3333
import { FooterItem } from './FooterItem';
34-
import { DEFAULT_THEME, getFloatingPlacements, useText } from '@zendeskgarden/react-theming';
34+
import {
35+
DEFAULT_THEME,
36+
getFloatingPlacements,
37+
useText,
38+
useDocument
39+
} from '@zendeskgarden/react-theming';
3540
import { createPortal } from 'react-dom';
3641

3742
const PLACEMENT_DEFAULT = 'top';
@@ -64,6 +69,7 @@ const TooltipDialogComponent = React.forwardRef<HTMLDivElement, ITooltipDialogPr
6469
ref
6570
) => {
6671
const theme = useContext(ThemeContext) || DEFAULT_THEME;
72+
const environment = useDocument(theme);
6773
const previousReferenceElementRef = useRef<HTMLElement | null>();
6874
const modalRef = useRef<HTMLDivElement>(null);
6975
const transitionRef = useRef<HTMLDivElement>(null);
@@ -76,7 +82,8 @@ const TooltipDialogComponent = React.forwardRef<HTMLDivElement, ITooltipDialogPr
7682
modalRef,
7783
focusOnMount,
7884
/** Handle `restoreFocus` locally to return focus to `referenceElement` */
79-
restoreFocus: false
85+
restoreFocus: false,
86+
environment
8087
});
8188

8289
const [floatingPlacement, fallbackPlacements] = getFloatingPlacements(

0 commit comments

Comments
 (0)