@scalio-cloud/ui 0.96.0 → 0.97.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/package.json +1 -1
- package/react/audit.js +11 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scalio-cloud/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.97.0",
|
|
4
4
|
"description": "Scalio Control Room design tokens, Tailwind preset, self-hosted fonts, the shared app header, sign-in layout, sidebar and page blocks",
|
|
5
5
|
"license": "SEE LICENSE IN README.md",
|
|
6
6
|
"private": false,
|
package/react/audit.js
CHANGED
|
@@ -6,6 +6,7 @@ const React = require("react");
|
|
|
6
6
|
const h = React.createElement;
|
|
7
7
|
const Icons = require("./icons");
|
|
8
8
|
const { SubNav } = require("./nav");
|
|
9
|
+
const { trapTab } = require("./wizard");
|
|
9
10
|
|
|
10
11
|
const LABELS = {
|
|
11
12
|
de: {
|
|
@@ -231,9 +232,18 @@ function Dialog({ title, onClose, children, testId, closeLabel }) {
|
|
|
231
232
|
document.addEventListener("keydown", key);
|
|
232
233
|
return () => document.removeEventListener("keydown", key);
|
|
233
234
|
}, [onClose]);
|
|
235
|
+
// Like askConfirm (dialog.js): focus goes in on open, Tab stays inside, focus returns to the trigger on close.
|
|
236
|
+
const panel = React.useRef(null);
|
|
237
|
+
React.useEffect(() => {
|
|
238
|
+
const before = document.activeElement;
|
|
239
|
+
const close = panel.current && panel.current.querySelector('[data-testid="dialog-close"]');
|
|
240
|
+
if (close) close.focus();
|
|
241
|
+
else if (panel.current) panel.current.focus();
|
|
242
|
+
return () => { if (before && typeof before.focus === "function" && document.contains(before)) before.focus(); };
|
|
243
|
+
}, []);
|
|
234
244
|
return h("div", { className: "scalio-dialog-root" },
|
|
235
245
|
h("div", { className: "scalio-dialog-backdrop", onClick: onClose }),
|
|
236
|
-
h("div", { className: "scalio-dialog scalio-audit-dialog", role: "dialog", "aria-modal": "true", "aria-label": title, "data-testid": testId },
|
|
246
|
+
h("div", { ref: panel, tabIndex: -1, onKeyDown: (e) => { if (e.key === "Tab") trapTab(e, panel.current); }, className: "scalio-dialog scalio-audit-dialog", role: "dialog", "aria-modal": "true", "aria-label": title, "data-testid": testId },
|
|
237
247
|
h("div", { className: "scalio-dialog-head" },
|
|
238
248
|
h("div", { className: "scalio-dialog-title" }, title),
|
|
239
249
|
h("button", { type: "button", className: "scalio-btn is-ghost scalio-btn-icon", onClick: onClose, "aria-label": closeLabel || "×", "data-testid": "dialog-close" },
|