@trackunit/react-modal 2.16.2 → 2.17.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -260,7 +260,7 @@ const SHEET_CONTAINER_STYLE = {
260
260
  };
261
261
  /**
262
262
  * Modal presents critical information or requests user input in an overlay dialog that interrupts the current workflow.
263
- * It renders inside a Portal with a backdrop overlay, focus trapping, and proper accessibility roles.
263
+ * It renders inside a portal with a backdrop overlay, focus trapping, and proper accessibility roles.
264
264
  * Modals must always be used together with the `useModal` hook, which manages open/close state and Floating UI integration.
265
265
  *
266
266
  * When the container width is below the "sm" breakpoint (480px), the Modal
@@ -299,6 +299,9 @@ const SHEET_CONTAINER_STYLE = {
299
299
  const Modal = ({ children, container, dismiss, isOpen, mode, requestClose, role = "dialog", "data-testid": dataTestId, className, size, stack, floatingUi, ref, sheetDefaultSize = "fit", restoreFocus = true, onCloseComplete, }) => {
300
300
  const { depthFromFront, stackSizeAtOpen } = stack;
301
301
  const { rootElement, refs, context, getFloatingProps } = floatingUi;
302
+ // Always pass an explicit root: without one, FloatingPortal nests inside a parent portal
303
+ // (e.g. a Sheet with `pointer-events: none`) instead of escaping to the body.
304
+ const portalRoot = rootElement ?? document.body;
302
305
  const cardRef = react.useRef(null);
303
306
  const mergedRef = react$1.useMergeRefs([refs.setFloating, ref]);
304
307
  const sheetRef = react.useRef(null);
@@ -382,19 +385,19 @@ const Modal = ({ children, container, dismiss, isOpen, mode, requestClose, role
382
385
  children,
383
386
  ]);
384
387
  if (mode === "sheet") {
385
- return (jsxRuntime.jsxs(reactComponents.Portal, { root: rootElement, children: [isContained ? (jsxRuntime.jsx(reactComponents.Portal, { root: container.current, children: jsxRuntime.jsx("div", { ref: setSheetContainer, style: sheetContainerStyle }) })) : container === undefined ? (jsxRuntime.jsx("div", { ref: setSheetContainer, style: sheetContainerStyle })) : null, jsxRuntime.jsx(reactComponents.Sheet, { container: sheetContainer, "data-testid": dataTestId, entryAnimation: modeState.isModeSwitching ? "never" : "always", isOpen: isOpen, onClickHandle: sheetOnClickHandle, onCloseComplete: handleSheetCloseComplete, onCloseGesture: onCloseGesture, onGeometryChange: sheetOnGeometryChange, onSnap: sheetOnSnap, ref: sheetPanelRef, snap: sheetSnap, snapping: true, state: sheetState, trapFocus: false, variant: depthFromFront === 0 ? "modal" : "default", children: jsxRuntime.jsx(react$1.FloatingFocusManager, { context: context, restoreFocus: restoreFocus, children: jsxRuntime.jsx("div", { "aria-modal": true, className: cvaModalContentEnvironment({ className: "flex-grow" }), "data-modal-content": true, ref: ref, role: role, ...getFloatingProps(), children: children }) }) })] }));
388
+ return (jsxRuntime.jsxs(react$1.FloatingPortal, { root: portalRoot, children: [isContained ? (jsxRuntime.jsx(react$1.FloatingPortal, { root: container.current, children: jsxRuntime.jsx("div", { ref: setSheetContainer, style: sheetContainerStyle }) })) : container === undefined ? (jsxRuntime.jsx("div", { ref: setSheetContainer, style: sheetContainerStyle })) : null, jsxRuntime.jsx(reactComponents.Sheet, { container: sheetContainer, "data-testid": dataTestId, entryAnimation: modeState.isModeSwitching ? "never" : "always", isOpen: isOpen, onClickHandle: sheetOnClickHandle, onCloseComplete: handleSheetCloseComplete, onCloseGesture: onCloseGesture, onGeometryChange: sheetOnGeometryChange, onSnap: sheetOnSnap, ref: sheetPanelRef, snap: sheetSnap, snapping: true, state: sheetState, trapFocus: false, variant: depthFromFront === 0 ? "modal" : "default", children: jsxRuntime.jsx(react$1.FloatingFocusManager, { context: context, restoreFocus: restoreFocus, children: jsxRuntime.jsx("div", { "aria-modal": true, className: cvaModalContentEnvironment({ className: "flex-grow" }), "data-modal-content": true, ref: ref, role: role, ...getFloatingProps(), children: children }) }) })] }));
386
389
  }
387
390
  if (cardModeInner === null) {
388
- return jsxRuntime.jsx(reactComponents.Portal, { root: rootElement, children: null });
391
+ return jsxRuntime.jsx(react$1.FloatingPortal, { root: portalRoot, children: null });
389
392
  }
390
393
  if (isContained) {
391
- return (jsxRuntime.jsx(reactComponents.Portal, { root: rootElement, children: jsxRuntime.jsx(reactComponents.Portal, { root: container.current, children: jsxRuntime.jsx("div", { className: cvaModalBackdrop({
394
+ return (jsxRuntime.jsx(react$1.FloatingPortal, { root: portalRoot, children: jsxRuntime.jsx(react$1.FloatingPortal, { root: container.current, children: jsxRuntime.jsx("div", { className: cvaModalBackdrop({
392
395
  contained: true,
393
396
  isFrontmost: depthFromFront === 0,
394
397
  shouldAnimate: stackSizeAtOpen === 0,
395
398
  }), children: cardModeInner }) }) }));
396
399
  }
397
- return (jsxRuntime.jsx(reactComponents.Portal, { root: rootElement, children: jsxRuntime.jsx(react$1.FloatingOverlay, { className: cvaModalBackdrop({ isFrontmost: depthFromFront === 0, shouldAnimate: stackSizeAtOpen === 0 }), lockScroll: true, children: cardModeInner }) }));
400
+ return (jsxRuntime.jsx(react$1.FloatingPortal, { root: portalRoot, children: jsxRuntime.jsx(react$1.FloatingOverlay, { className: cvaModalBackdrop({ isFrontmost: depthFromFront === 0, shouldAnimate: stackSizeAtOpen === 0 }), lockScroll: true, children: cardModeInner }) }));
398
401
  };
399
402
 
400
403
  const cvaModalBodyContainer = cssClassVarianceUtilities.cva({
package/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { registerTranslations, useNamespaceTranslation } from '@trackunit/i18n-library-translation';
3
- import { useMergeRefs, FloatingFocusManager, FloatingOverlay, useFloating, autoUpdate, shift, useDismiss, useInteractions } from '@floating-ui/react';
4
- import { useOverflowBorder, useSheetSnap, useWatch, Card, Portal, Sheet, Button, Heading, Text, IconButton, Icon, useContainerBreakpoints, useViewportBreakpoints, useTimeout, SHEET_TRANSITION_DURATION_MS } from '@trackunit/react-components';
3
+ import { useMergeRefs, FloatingFocusManager, FloatingPortal, FloatingOverlay, useFloating, autoUpdate, shift, useDismiss, useInteractions } from '@floating-ui/react';
4
+ import { useOverflowBorder, useSheetSnap, useWatch, Card, Sheet, Button, Heading, Text, IconButton, Icon, useContainerBreakpoints, useViewportBreakpoints, useTimeout, SHEET_TRANSITION_DURATION_MS } from '@trackunit/react-components';
5
5
  import { useRef, useEffect, useCallback, useState, useReducer, useMemo, useId, useSyncExternalStore, useLayoutEffect, useContext } from 'react';
6
6
  import { cva } from '@trackunit/css-class-variance-utilities';
7
7
  import { ModalDialogContext, ErrorHandlingContext } from '@trackunit/react-core-contexts-api';
@@ -258,7 +258,7 @@ const SHEET_CONTAINER_STYLE = {
258
258
  };
259
259
  /**
260
260
  * Modal presents critical information or requests user input in an overlay dialog that interrupts the current workflow.
261
- * It renders inside a Portal with a backdrop overlay, focus trapping, and proper accessibility roles.
261
+ * It renders inside a portal with a backdrop overlay, focus trapping, and proper accessibility roles.
262
262
  * Modals must always be used together with the `useModal` hook, which manages open/close state and Floating UI integration.
263
263
  *
264
264
  * When the container width is below the "sm" breakpoint (480px), the Modal
@@ -297,6 +297,9 @@ const SHEET_CONTAINER_STYLE = {
297
297
  const Modal = ({ children, container, dismiss, isOpen, mode, requestClose, role = "dialog", "data-testid": dataTestId, className, size, stack, floatingUi, ref, sheetDefaultSize = "fit", restoreFocus = true, onCloseComplete, }) => {
298
298
  const { depthFromFront, stackSizeAtOpen } = stack;
299
299
  const { rootElement, refs, context, getFloatingProps } = floatingUi;
300
+ // Always pass an explicit root: without one, FloatingPortal nests inside a parent portal
301
+ // (e.g. a Sheet with `pointer-events: none`) instead of escaping to the body.
302
+ const portalRoot = rootElement ?? document.body;
300
303
  const cardRef = useRef(null);
301
304
  const mergedRef = useMergeRefs([refs.setFloating, ref]);
302
305
  const sheetRef = useRef(null);
@@ -380,19 +383,19 @@ const Modal = ({ children, container, dismiss, isOpen, mode, requestClose, role
380
383
  children,
381
384
  ]);
382
385
  if (mode === "sheet") {
383
- return (jsxs(Portal, { root: rootElement, children: [isContained ? (jsx(Portal, { root: container.current, children: jsx("div", { ref: setSheetContainer, style: sheetContainerStyle }) })) : container === undefined ? (jsx("div", { ref: setSheetContainer, style: sheetContainerStyle })) : null, jsx(Sheet, { container: sheetContainer, "data-testid": dataTestId, entryAnimation: modeState.isModeSwitching ? "never" : "always", isOpen: isOpen, onClickHandle: sheetOnClickHandle, onCloseComplete: handleSheetCloseComplete, onCloseGesture: onCloseGesture, onGeometryChange: sheetOnGeometryChange, onSnap: sheetOnSnap, ref: sheetPanelRef, snap: sheetSnap, snapping: true, state: sheetState, trapFocus: false, variant: depthFromFront === 0 ? "modal" : "default", children: jsx(FloatingFocusManager, { context: context, restoreFocus: restoreFocus, children: jsx("div", { "aria-modal": true, className: cvaModalContentEnvironment({ className: "flex-grow" }), "data-modal-content": true, ref: ref, role: role, ...getFloatingProps(), children: children }) }) })] }));
386
+ return (jsxs(FloatingPortal, { root: portalRoot, children: [isContained ? (jsx(FloatingPortal, { root: container.current, children: jsx("div", { ref: setSheetContainer, style: sheetContainerStyle }) })) : container === undefined ? (jsx("div", { ref: setSheetContainer, style: sheetContainerStyle })) : null, jsx(Sheet, { container: sheetContainer, "data-testid": dataTestId, entryAnimation: modeState.isModeSwitching ? "never" : "always", isOpen: isOpen, onClickHandle: sheetOnClickHandle, onCloseComplete: handleSheetCloseComplete, onCloseGesture: onCloseGesture, onGeometryChange: sheetOnGeometryChange, onSnap: sheetOnSnap, ref: sheetPanelRef, snap: sheetSnap, snapping: true, state: sheetState, trapFocus: false, variant: depthFromFront === 0 ? "modal" : "default", children: jsx(FloatingFocusManager, { context: context, restoreFocus: restoreFocus, children: jsx("div", { "aria-modal": true, className: cvaModalContentEnvironment({ className: "flex-grow" }), "data-modal-content": true, ref: ref, role: role, ...getFloatingProps(), children: children }) }) })] }));
384
387
  }
385
388
  if (cardModeInner === null) {
386
- return jsx(Portal, { root: rootElement, children: null });
389
+ return jsx(FloatingPortal, { root: portalRoot, children: null });
387
390
  }
388
391
  if (isContained) {
389
- return (jsx(Portal, { root: rootElement, children: jsx(Portal, { root: container.current, children: jsx("div", { className: cvaModalBackdrop({
392
+ return (jsx(FloatingPortal, { root: portalRoot, children: jsx(FloatingPortal, { root: container.current, children: jsx("div", { className: cvaModalBackdrop({
390
393
  contained: true,
391
394
  isFrontmost: depthFromFront === 0,
392
395
  shouldAnimate: stackSizeAtOpen === 0,
393
396
  }), children: cardModeInner }) }) }));
394
397
  }
395
- return (jsx(Portal, { root: rootElement, children: jsx(FloatingOverlay, { className: cvaModalBackdrop({ isFrontmost: depthFromFront === 0, shouldAnimate: stackSizeAtOpen === 0 }), lockScroll: true, children: cardModeInner }) }));
398
+ return (jsx(FloatingPortal, { root: portalRoot, children: jsx(FloatingOverlay, { className: cvaModalBackdrop({ isFrontmost: depthFromFront === 0, shouldAnimate: stackSizeAtOpen === 0 }), lockScroll: true, children: cardModeInner }) }));
396
399
  };
397
400
 
398
401
  const cvaModalBodyContainer = cva({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-modal",
3
- "version": "2.16.2",
3
+ "version": "2.17.6",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -8,12 +8,12 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@floating-ui/react": "^0.26.25",
11
- "@trackunit/react-components": "5.0.1",
12
- "@trackunit/css-class-variance-utilities": "2.6.10",
13
- "@trackunit/shared-utils": "1.22.10",
11
+ "@trackunit/react-components": "6.0.5",
12
+ "@trackunit/css-class-variance-utilities": "2.6.15",
13
+ "@trackunit/shared-utils": "1.22.15",
14
14
  "@floating-ui/react-dom": "2.1.2",
15
- "@trackunit/react-core-contexts-api": "1.27.1",
16
- "@trackunit/i18n-library-translation": "2.13.2"
15
+ "@trackunit/react-core-contexts-api": "1.28.5",
16
+ "@trackunit/i18n-library-translation": "2.14.5"
17
17
  },
18
18
  "peerDependencies": {
19
19
  "@tanstack/react-router": "^1.114.29",
@@ -34,7 +34,7 @@ export type ModalProps = PropsWithChildren<UseModalReturnValue & {
34
34
  }>;
35
35
  /**
36
36
  * Modal presents critical information or requests user input in an overlay dialog that interrupts the current workflow.
37
- * It renders inside a Portal with a backdrop overlay, focus trapping, and proper accessibility roles.
37
+ * It renders inside a portal with a backdrop overlay, focus trapping, and proper accessibility roles.
38
38
  * Modals must always be used together with the `useModal` hook, which manages open/close state and Floating UI integration.
39
39
  *
40
40
  * When the container width is below the "sm" breakpoint (480px), the Modal