@scalewing/react 1.59.2 → 1.59.3

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
@@ -1,5 +1,11 @@
1
1
  # @scalewing/react
2
2
 
3
+ ## 1.59.3
4
+
5
+ ### Patch Changes
6
+
7
+ - f929c5c: A `Dialog` unmounted while open (a consumer that renders it only while it is open) now closes first, while it is still in the document, so the browser hands focus back to the element that had it when the dialog opened, as a dialog closed by `open={false}` does; removed while open, a modal dialog left focus on the body (WCAG 2.4.3). `onClose` is not asked. A `ContextSwitcher` trigger's muted words read as the text colour while it is open or hovered, on its quiet fill (4.14:1 before), as rows already do. No API change.
8
+
3
9
  ## 1.59.2
4
10
 
5
11
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- import { useEffect, useRef, useState, } from 'react';
1
+ import { useEffect, useLayoutEffect, useRef, useState, } from 'react';
2
2
  /**
3
3
  * A press on the backdrop: the target is the dialog element itself (not a
4
4
  * child, a nested dialog's backdrop, or a popover that overflows the box)
@@ -77,6 +77,21 @@ export function useDialogCloseRequests({ open, onClose, onCancel, onKeyDown, onP
77
77
  if (!open && node.open)
78
78
  node.close();
79
79
  }, [open, browserCloses]);
80
+ // A consumer that renders the dialog only while it is open unmounts it
81
+ // instead of passing `open={false}`. Closing it first, while it is still
82
+ // in the document (a layout cleanup runs before React removes the node),
83
+ // lets the browser hand focus back to the element that had it when the
84
+ // dialog opened, as a dialog closed by its prop does. Removed while open,
85
+ // a modal dialog leaves focus on the body (WCAG 2.4.3).
86
+ useLayoutEffect(() => {
87
+ const node = nodeRef.current;
88
+ return () => {
89
+ if (!node?.open)
90
+ return;
91
+ openRef.current = false;
92
+ node.close();
93
+ };
94
+ }, []);
80
95
  function handleKeyDown(event) {
81
96
  onKeyDown?.(event);
82
97
  // A nested control (a menu, a listbox, a tooltip, an inner dialog) or the
@@ -1,6 +1,6 @@
1
1
  import { typographyVariants } from '@scalewing/tokens';
2
2
  import { chevronStroke } from './chevron.js';
3
- import { quietFill } from './quiet-fill.js';
3
+ import { mutedReadsAsText, quietFill } from './quiet-fill.js';
4
4
  import { coarsePointerQuery, touchTarget } from './touch-target.js';
5
5
  const label = typographyVariants.label;
6
6
  export const contextSwitcherTriggerAppearances = [
@@ -91,6 +91,13 @@ ${trigger}[aria-expanded='true'] {
91
91
  }
92
92
  }
93
93
 
94
+ /* The consumer's muted words on the quiet fill read as the text colour (4.14:1 before). */
95
+ ${mutedReadsAsText([`${trigger}[aria-expanded='true'] *`])}
96
+
97
+ @media (hover: hover) {
98
+ ${mutedReadsAsText([`${trigger}:hover *`])}
99
+ }
100
+
94
101
  ${trigger}:focus-visible {
95
102
  outline: var(--sw-focus-ring-width) solid var(--sw-color-accent);
96
103
  outline-offset: var(--sw-focus-ring-offset);
package/dist/styles.css CHANGED
@@ -7128,6 +7128,17 @@ html:has(.sw-site-header-sticky) {
7128
7128
  }
7129
7129
  }
7130
7130
 
7131
+ /* The consumer's muted words on the quiet fill read as the text colour (4.14:1 before). */
7132
+ .sw-context-switcher-trigger[aria-expanded='true'] * {
7133
+ --sw-color-muted: var(--sw-color-text);
7134
+ }
7135
+
7136
+ @media (hover: hover) {
7137
+ .sw-context-switcher-trigger:hover * {
7138
+ --sw-color-muted: var(--sw-color-text);
7139
+ }
7140
+ }
7141
+
7131
7142
  .sw-context-switcher-trigger:focus-visible {
7132
7143
  outline: var(--sw-focus-ring-width) solid var(--sw-color-accent);
7133
7144
  outline-offset: var(--sw-focus-ring-offset);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalewing/react",
3
- "version": "1.59.2",
3
+ "version": "1.59.3",
4
4
  "description": "Scalewing DOM components and package-owned CSS utilities.",
5
5
  "type": "module",
6
6
  "license": "MIT",