@synerise/ds-modal 1.7.0 → 2.0.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.0.0](https://github.com/synerise/synerise-design/compare/@synerise/ds-modal@1.7.1...@synerise/ds-modal@2.0.0) (2026-08-26)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-modal
9
+
10
+ ## [1.7.1](https://github.com/synerise/synerise-design/compare/@synerise/ds-modal@1.7.0...@synerise/ds-modal@1.7.1) (2026-08-20)
11
+
12
+ ### Bug Fixes
13
+
14
+ - stack nested modals above their enclosing overlay ([c7f75c0](https://github.com/synerise/synerise-design/commit/c7f75c0fb39dc29e23997364640a2733811e4b51))
15
+
6
16
  # [1.7.0](https://github.com/synerise/synerise-design/compare/@synerise/ds-modal@1.6.9...@synerise/ds-modal@1.7.0) (2026-08-18)
7
17
 
8
18
  ### Features
package/CLAUDE.md CHANGED
@@ -75,7 +75,7 @@ src/
75
75
  | `closeButtonAriaLabel` | `string` | `DS.MODAL.CLOSE` (`'Close'`) | Accessible name for the close button; defaults to the localised translation |
76
76
  | `initialFocusRef` | `RefObject<HTMLElement \| null>` | dialog container | Element focused on open. Defaults to the dialog container (announced by its accessible name). Pass a ref only when focusing a specific control is genuinely useful (search/rename dialogs) |
77
77
  | `getContainer` | `() => HTMLElement` | `document.body` | Portal mount target |
78
- | `zIndex` | `number` | theme `zindex-modal` | z-index of the modal root |
78
+ | `zIndex` | `number` | derived, see below | z-index of the modal root. Omit it and the modal stacks `OVERLAY_Z_INDEX_STEP` (2) above the nearest enclosing modal/drawer, falling back to the `zindex-modal` token when nothing encloses it. Set it to opt out of the stack entirely |
79
79
 
80
80
  ### `showModal(props: ModalProps): ModalHandle`
81
81
 
@@ -171,6 +171,7 @@ document.body (portal target)
171
171
  - **`fullScreen`** positions the modal `fixed` covering the viewport; body scrolls via `overflow: scroll`.
172
172
  - **`maxViewportHeight`** anchors the modal to the bottom of the viewport (sheet-style), not the centre.
173
173
  - **Async handlers:** Both `onOk` and `onCancel` can return `Promise`. `onCancel` awaits the promise then calls `closeModal()`. `onOk` resolves then calls `closeModal()` only if the handler was detected as promise-returning via `'then' in onOk`.
174
+ - **Nested-modal stacking:** `ModalContent` resolves its z-index through `useResolvedOverlayZIndex` from `@synerise/ds-core` and re-publishes the result to its whole subtree via `OverlayZIndexProvider`, so a modal opened from inside another modal renders above it without either side coordinating. This cannot be left to DOM order: every modal portals to `document.body` and React commits the **innermost** portal first, so a nested modal ends up *before* its parent in the document. The provider wraps `ModalRoot` rather than just `children`, so a modal passed through `prefix` / `footer` / `headerActions` stacks too. An explicit `zIndex` always wins and is not clamped; derived values are clamped just below `zindex-dropdown` so a modal can never cover a dropdown, select, popconfirm or tooltip opened inside it. `showModal()` renders at `DSProvider` level, outside any modal's React subtree, so it never derives — pass `zIndex` there if it must stack. See "Overlay z-index" in `@synerise/ds-core`'s CLAUDE.md.
174
175
  - **Accessibility:** `ModalContainer` carries `role="dialog"` + `aria-modal`. `ModalContent` generates two ids with React's `useId()` — `titleId` and `descriptionId` — passed to `ModalTitle` which applies them to `S.Title` (the `<h3>`) and `S.Description`. The dialog references them via `aria-labelledby` (when `title` is set) and `aria-describedby` (when `description` is set); `aria-label` falls back to the `ariaLabel` prop when there is no title. Both close buttons (header and `blank`) get `aria-label` from `closeButtonAriaLabel`, falling back to the localised `DS.MODAL.CLOSE` message (`useIntl().formatMessage`, default `'Close'`); `react-intl` is a peer dependency. Focus trap/restore is handled by `useFocusTrap`; `Escape` closes via `handleKeyDown`. **Initial focus:** on open, focus moves to the `ModalContainer` (`role="dialog"`, `tabIndex={-1}`) itself — screen readers announce the dialog's accessible name + role and no cursor lands in a non-critical field. This satisfies the WAI-ARIA APG Dialog pattern (focus must move *into* the dialog, but not necessarily onto the first focusable element). Consumers can override the target with `initialFocusRef` (e.g. focus a search field); it is passed straight to `useFocusTrap`'s `initialFocus` option.
175
176
 
176
177
  ## Key dependencies
@@ -1,6 +1,6 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef, useRef, useId, useMemo, useCallback, useImperativeHandle, useEffect } from "react";
3
- import { registerOverlay, createOverlayCloseEvent } from "@synerise/ds-core";
3
+ import { useResolvedOverlayZIndex, registerOverlay, createOverlayCloseEvent, OverlayZIndexProvider } from "@synerise/ds-core";
4
4
  import { useLatestRef, useFocusTrap } from "@synerise/ds-utils";
5
5
  import { SIZE_MAP } from "../../Modal.const.js";
6
6
  import { ModalFooter } from "../ModalFooter/ModalFooter.js";
@@ -45,9 +45,11 @@ const ModalContent = forwardRef(({
45
45
  ariaLabel,
46
46
  closeButtonAriaLabel,
47
47
  initialFocusRef,
48
+ zIndex,
48
49
  ...rest
49
50
  }, modalRef) => {
50
51
  const scrollRef = useRef(null);
52
+ const resolvedZIndex = useResolvedOverlayZIndex(zIndex);
51
53
  const titleId = useId();
52
54
  const descriptionId = useId();
53
55
  const DEFAULT_VIEWPORT_HEIGHT = 80;
@@ -117,7 +119,7 @@ const ModalContent = forwardRef(({
117
119
  useFocusTrap(containerRef, !hidden, {
118
120
  initialFocus: initialFocusRef ?? dialogRef
119
121
  });
120
- return /* @__PURE__ */ jsxs(ModalRoot, { "data-testid": "ds-modal", ...rest, $hidden: hidden, "data-visible": !hidden, onKeyDown: handleKeyDown, tabIndex: -1, ref: containerRef, children: [
122
+ return /* @__PURE__ */ jsx(OverlayZIndexProvider, { value: resolvedZIndex, children: /* @__PURE__ */ jsxs(ModalRoot, { "data-testid": "ds-modal", ...rest, zIndex: resolvedZIndex, $hidden: hidden, "data-visible": !hidden, onKeyDown: handleKeyDown, tabIndex: -1, ref: containerRef, children: [
121
123
  /* @__PURE__ */ jsx(ModalMask, {}),
122
124
  /* @__PURE__ */ jsx(ModalScrollWrap, { ref: scrollRef, onClick: handleMaskClick, children: /* @__PURE__ */ jsxs(ModalContainer, { ref: dialogRef, tabIndex: -1, onClick: cancelClick, role: "dialog", "aria-modal": true, "aria-labelledby": title ? titleId : void 0, "aria-label": !title ? ariaLabel : void 0, "aria-describedby": description ? descriptionId : void 0, isFullscreen, $width: size && SIZE_MAP[size], maxHeight, centered, children: [
123
125
  /* @__PURE__ */ jsx(ModalTitle, { headerActions, blank, titleContainerStyle, onCancel: closable && onCancel ? handleCancel : void 0, title, titleId, description, descriptionId, headerTabProps, headerBottomBar, closeButtonAriaLabel }),
@@ -126,7 +128,7 @@ const ModalContent = forwardRef(({
126
128
  }, absolute: true, classes: "ds-modal-body-scrollbar", ref: bodyScrollRef, children }) }) : children }),
127
129
  /* @__PURE__ */ jsx(ModalFooter, { CustomFooterButton, prefix, infix, suffix, onOk: onOk ? handleOk : void 0, onCancel: onCancel ? handleCancel : void 0, texts, okButton, okButtonProps, cancelButton, cancelButtonProps, cancelText, okText, okType, footer })
128
130
  ] }) })
129
- ] });
131
+ ] }) });
130
132
  });
131
133
  export {
132
134
  ModalContent
@@ -176,8 +176,10 @@ export type ModalProps = {
176
176
  /** Inline styles applied to the modal body element. */
177
177
  bodyStyle?: CSSProperties;
178
178
  /**
179
- * `z-index` of the modal root.
180
- * @defaultValue theme `zindex-modal`
179
+ * `z-index` of the modal root. Omit it and the modal stacks one step above
180
+ * the nearest enclosing modal/drawer, falling back to the `zindex-modal`
181
+ * token when nothing encloses it. Set it to opt out of that stack.
182
+ * @defaultValue derived from the enclosing overlay, else theme `zindex-modal`
181
183
  */
182
184
  zIndex?: number;
183
185
  /** CSS class applied to the modal root. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-modal",
3
- "version": "1.7.0",
3
+ "version": "2.0.0",
4
4
  "description": "Modal UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "synerise/synerise-design",
@@ -39,14 +39,16 @@
39
39
  "sideEffects": false,
40
40
  "types": "dist/index.d.ts",
41
41
  "dependencies": {
42
- "@synerise/ds-button": "^1.5.37",
43
- "@synerise/ds-icon": "^1.18.5",
44
- "@synerise/ds-scrollbar": "^1.5.2",
45
- "@synerise/ds-tabs": "^1.2.10",
46
- "@synerise/ds-typography": "^1.1.29",
47
- "@synerise/ds-utils": "^1.10.2"
42
+ "@synerise/ds-button": "^2.0.0",
43
+ "@synerise/ds-icon": "^2.0.0",
44
+ "@synerise/ds-scrollbar": "^2.0.0",
45
+ "@synerise/ds-tabs": "^2.0.0",
46
+ "@synerise/ds-typography": "^2.0.0",
47
+ "@synerise/ds-utils": "^2.0.0"
48
48
  },
49
49
  "devDependencies": {
50
+ "@synerise/ds-dropdown": "^2.0.0",
51
+ "@synerise/ds-popconfirm": "^2.0.0",
50
52
  "vitest": "4"
51
53
  },
52
54
  "peerDependencies": {
@@ -55,5 +57,5 @@
55
57
  "react-intl": ">=3.12.0 <= 6.8",
56
58
  "styled-components": "^5.3.3"
57
59
  },
58
- "gitHead": "e1fece64a41fd18a78583ecb6c21ee00fe8c0759"
60
+ "gitHead": "033854a18f038079e9a16b0ff250f8401a2287c2"
59
61
  }