@synerise/ds-modal 1.6.8 → 1.7.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
+ # [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
+
8
+ ### Features
9
+
10
+ - **modal:** close open modals via closeAllOverlays ([208e41c](https://github.com/synerise/synerise-design/commit/208e41c7e0b2e905b170f98ec58d302a86c04932))
11
+
12
+ ## [1.6.9](https://github.com/synerise/synerise-design/compare/@synerise/ds-modal@1.6.8...@synerise/ds-modal@1.6.9) (2026-08-14)
13
+
14
+ **Note:** Version bump only for package @synerise/ds-modal
15
+
6
16
  ## [1.6.8](https://github.com/synerise/synerise-design/compare/@synerise/ds-modal@1.6.7...@synerise/ds-modal@1.6.8) (2026-08-11)
7
17
 
8
18
  **Note:** Version bump only for package @synerise/ds-modal
package/README.md CHANGED
@@ -205,3 +205,14 @@ The following prop is **deprecated** and will be removed in a future major versi
205
205
  | Prop | Replacement |
206
206
  | ---- | ----------- |
207
207
  | `description` | `headerBottomBar` |
208
+
209
+ ## Closing programmatically
210
+
211
+ `closeAllOverlays()` from `@synerise/ds-core` force-closes every open DS overlay in one call — useful when an app-level event (e.g. the active workspace changed in another tab) invalidates whatever the user is doing. This component closes through its own close path, so its handlers fire and focus is restored.
212
+
213
+ ```ts
214
+ import { closeAllOverlays } from '@synerise/ds-core';
215
+
216
+ await closeAllOverlays();
217
+ await closeAllOverlays({ kinds: ['modal', 'drawer'] }); // leave tooltips alone
218
+ ```
@@ -1,6 +1,7 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { forwardRef, useRef, useId, useMemo, useCallback, useImperativeHandle } from "react";
3
- import { useFocusTrap } from "@synerise/ds-utils";
2
+ import { forwardRef, useRef, useId, useMemo, useCallback, useImperativeHandle, useEffect } from "react";
3
+ import { registerOverlay, createOverlayCloseEvent } from "@synerise/ds-core";
4
+ import { useLatestRef, useFocusTrap } from "@synerise/ds-utils";
4
5
  import { SIZE_MAP } from "../../Modal.const.js";
5
6
  import { ModalFooter } from "../ModalFooter/ModalFooter.js";
6
7
  import { ModalTitle } from "../ModalTitle/ModalTitle.js";
@@ -103,6 +104,16 @@ const ModalContent = forwardRef(({
103
104
  };
104
105
  const containerRef = useRef(null);
105
106
  const dialogRef = useRef(null);
107
+ const handleCancelRef = useLatestRef(handleCancel);
108
+ useEffect(() => {
109
+ if (hidden) {
110
+ return void 0;
111
+ }
112
+ return registerOverlay({
113
+ kind: "modal",
114
+ close: () => handleCancelRef.current(createOverlayCloseEvent(containerRef.current))
115
+ });
116
+ }, [hidden, handleCancelRef]);
106
117
  useFocusTrap(containerRef, !hidden, {
107
118
  initialFocus: initialFocusRef ?? dialogRef
108
119
  });
package/dist/Modal.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { forwardRef, useState, useRef, useEffect } from "react";
3
3
  import { createPortal } from "react-dom";
4
+ import { useLatestRef } from "@synerise/ds-utils";
4
5
  import { ModalContent } from "./Elements/ModalContent/ModalContent.js";
5
6
  const Modal = forwardRef(({
6
7
  open,
@@ -12,19 +13,20 @@ const Modal = forwardRef(({
12
13
  const [isOpen, setIsOpen] = useState(open);
13
14
  const [hasBeenOpened, setHasBeenOpened] = useState(open);
14
15
  const prevOpenRef = useRef(open);
16
+ const afterCloseRef = useLatestRef(afterClose);
15
17
  useEffect(() => {
16
18
  setIsOpen(open);
17
19
  if (open) {
18
20
  setHasBeenOpened(true);
19
21
  } else if (prevOpenRef.current) {
20
- afterClose?.();
22
+ afterCloseRef.current?.();
21
23
  }
22
24
  prevOpenRef.current = open;
23
- }, [open, afterClose]);
25
+ }, [open, afterCloseRef]);
24
26
  const closeModal = () => {
25
27
  setIsOpen((prev) => {
26
28
  if (prev) {
27
- afterClose?.();
29
+ afterCloseRef.current?.();
28
30
  }
29
31
  return false;
30
32
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-modal",
3
- "version": "1.6.8",
3
+ "version": "1.7.0",
4
4
  "description": "Modal UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "synerise/synerise-design",
@@ -39,11 +39,11 @@
39
39
  "sideEffects": false,
40
40
  "types": "dist/index.d.ts",
41
41
  "dependencies": {
42
- "@synerise/ds-button": "^1.5.36",
42
+ "@synerise/ds-button": "^1.5.37",
43
43
  "@synerise/ds-icon": "^1.18.5",
44
44
  "@synerise/ds-scrollbar": "^1.5.2",
45
- "@synerise/ds-tabs": "^1.2.8",
46
- "@synerise/ds-typography": "^1.1.28",
45
+ "@synerise/ds-tabs": "^1.2.10",
46
+ "@synerise/ds-typography": "^1.1.29",
47
47
  "@synerise/ds-utils": "^1.10.2"
48
48
  },
49
49
  "devDependencies": {
@@ -55,5 +55,5 @@
55
55
  "react-intl": ">=3.12.0 <= 6.8",
56
56
  "styled-components": "^5.3.3"
57
57
  },
58
- "gitHead": "6df24ed12cd5f276d8eccde730591807982e3385"
58
+ "gitHead": "e1fece64a41fd18a78583ecb6c21ee00fe8c0759"
59
59
  }