actual-css 0.19.3 → 0.19.5

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +2 -2
  3. package/dist/actual.full.css +8 -4
  4. package/dist/actual.full.js +2 -2
  5. package/dist/actual.full.min.css +1 -1
  6. package/dist/types/surface-focus.d.ts +2 -0
  7. package/docs/pages/components/dialog.md +3 -0
  8. package/docs/pages/components/list.md +1 -1
  9. package/docs/pages/components/timeline.md +4 -2
  10. package/docs/pages/enhancements/flyout.md +26 -8
  11. package/docs/pages/forms/joined-controls.md +1 -1
  12. package/docs/pages/forms/switch.md +4 -2
  13. package/docs/pages/foundations/theming.md +3 -0
  14. package/docs/pages/foundations/tokens.md +13 -13
  15. package/llms.txt +3 -3
  16. package/package.json +4 -5
  17. package/src/cli/actual-css.js +3 -3
  18. package/src/css/components/menu.css +2 -2
  19. package/src/css/forms/switch.css +6 -2
  20. package/src/js/dialog.js +30 -11
  21. package/src/js/surface-focus.js +14 -0
  22. package/src/js/surface.js +8 -3
  23. package/src/tooling/theme-contrast.js +6 -2
  24. package/docs/design-notes/accessibility-decisions.md +0 -65
  25. package/docs/design-notes/app-ui.md +0 -67
  26. package/docs/design-notes/architecture.md +0 -70
  27. package/docs/design-notes/browser-support.md +0 -239
  28. package/docs/design-notes/cascade-layer.md +0 -74
  29. package/docs/design-notes/column-layout.md +0 -260
  30. package/docs/design-notes/css-anchor.md +0 -87
  31. package/docs/design-notes/enhancement-contract.md +0 -193
  32. package/docs/design-notes/forced-colors.md +0 -123
  33. package/docs/design-notes/grid.md +0 -785
  34. package/docs/design-notes/motion-cost.md +0 -62
  35. package/docs/design-notes/naming.md +0 -71
  36. package/docs/design-notes/platform-alignment.md +0 -602
  37. package/docs/design-notes/popover-manual-poc.md +0 -328
  38. package/docs/design-notes/references.md +0 -336
  39. package/docs/design-notes/rich-text.md +0 -61
  40. package/docs/design-notes/spacing-units.md +0 -286
  41. package/docs/design-notes/steps.md +0 -776
  42. package/docs/design-notes/surface-reparenting.md +0 -130
  43. package/docs/design-notes/tokens.md +0 -166
  44. package/docs/design-notes/tooltip-coordinate-space.md +0 -130
  45. package/docs/design-notes/widget-primitives.md +0 -144
  46. package/docs/navigation.json +0 -176
@@ -0,0 +1,2 @@
1
+ export declare const surfaceFocusReturns: WeakMap<WeakKey, any>;
2
+ export declare function findFocusSurface(element: any): any;
@@ -87,6 +87,9 @@ The command runtime is stateless and does not pre-scan triggers.
87
87
  Use `command="request-close"` for cancel-style buttons so close requests go
88
88
  through the dialog's cancel lifecycle.
89
89
 
90
+ When a flyout command opens a dialog, closing the dialog returns focus to the
91
+ command if it can still receive focus, or to the button that opened the flyout.
92
+
90
93
  Use `closedby="any"` as the no-JavaScript light-dismiss path: the native dialog
91
94
  closes on backdrop click and Escape. Add `data-dialog-dismissible` so the
92
95
  optional runtime takes over backdrop click and closes with the dialog's
@@ -130,7 +130,7 @@ wiring.
130
130
  <menu class="flyout sm menu" id="member-actions" hidden>
131
131
  <li><button class="menu-item" type="button">Manage access</button></li>
132
132
  <li><button class="menu-item" type="button">Copy invite link</button></li>
133
- <hr class="menu-separator">
133
+ <li class="menu-separator" aria-hidden="true"></li>
134
134
  <li><button class="menu-item danger" type="button">Remove member</button></li>
135
135
  </menu>
136
136
  </div>
@@ -100,7 +100,9 @@ local `translate` to the inner glyph. Keep the disc in place:
100
100
 
101
101
  `.timeline-dates-end` moves each `<time>` to the end of the event's first
102
102
  line, so the titles lead and the dates line up in a column on the right.
103
- Write the `<time>` first in the event, as usual.
103
+ Write the `<time>` first in the event. Use an inline `<a>` for a linked title
104
+ that can wrap beside the date. A `.btn` moves below the date as a unit when
105
+ there is too little room beside it.
104
106
 
105
107
  It suits a narrow container: a sidebar, a card, a side panel. In a wide
106
108
  column the dates drift away from their titles; cap the list's width or keep
@@ -112,7 +114,7 @@ the default dateline.
112
114
  <li class="success">
113
115
  <i class="ti ti-check" aria-hidden="true"></i>
114
116
  <time datetime="2026-11-11T09:40">09:40</time>
115
- <strong>Results available</strong>
117
+ <strong><a href="#">Results available</a></strong>
116
118
  <p class="muted">Reviewed by the attending physician.</p>
117
119
  </li>
118
120
  <li class="primary">
@@ -18,10 +18,11 @@
18
18
  | `.menu-item-text` | Slot | Flexible label column; truncates. |
19
19
  | `.menu-item-end` | Slot | Trailing shortcut, badge or status. |
20
20
  | `.menu-label` | Variant | Muted, non-interactive group heading. |
21
- | `.menu-separator` | Variant | Divider between menu groups (`<hr>`). |
21
+ | `.menu-separator` | Variant | Divider row between groups. |
22
22
  | `.sm` / `.lg` | Size | Smaller or larger menu rows and type. |
23
23
 
24
- `.menu` has a strict `.menu > li > .menu-item` anatomy.
24
+ Action rows use `.menu > li > .menu-item`. Labels and dividers use their own
25
+ `<li>` rows.
25
26
 
26
27
  ## Usage
27
28
 
@@ -207,7 +208,7 @@ A list of *actions* the user can take: sign out, copy, delete.
207
208
  - Flyout triggers are opt-in: add `data-enhance="flyout"` to the trigger.
208
209
  - Wrap the trigger and flyout in `.flyout-trigger` when the flyout should have a local absolute-position fallback before JavaScript positions it. Add `.stretch` when the trigger must span its container, such as the last row of a full-width sidebar nav list.
209
210
  - Use `<menu class="flyout menu">` with strict anatomy: `.menu > li > .menu-item`. Items must carry the `.menu-item` class to participate in directional keyboard navigation. ArrowUp/Down and Home/End move focus without rewriting their normal tab stops.
210
- - Use `.menu-label` on a `li` for a muted section heading inside a menu (e.g. a group title before its items). It is non-interactive and does not participate in roving focus. Use `.menu-separator` (a plain `<hr>`) between groups.
211
+ - Use `<li class="menu-label">` for a section label and `<li class="menu-separator" aria-hidden="true"></li>` for a decorative divider in a plain action list. Keyboard navigation skips both rows.
211
212
  - Items are regular `<button>` or `<a>` elements.
212
213
  - Use `.sm` or `.lg` to scale one flyout; use a density context for surrounding UI.
213
214
  - Add `role="menu"` / `role="menuitem"` only when you intentionally need the ARIA menu pattern described below.
@@ -230,7 +231,7 @@ A list of *actions* the user can take: sign out, copy, delete.
230
231
  hidden>
231
232
  <li><button class="menu-item" type="button">Profile</button></li>
232
233
  <li><button class="menu-item" type="button">Settings</button></li>
233
- <hr class="menu-separator">
234
+ <li class="menu-separator" aria-hidden="true"></li>
234
235
  <li><button class="menu-item danger" type="button">Sign out</button></li>
235
236
  </menu>
236
237
  </div>
@@ -248,6 +249,18 @@ tab stop instead.
248
249
  The runtime owns only focus movement and `tabindex`. The application still owns
249
250
  command state and updates attributes such as `aria-checked`.
250
251
 
252
+ In an ARIA menu, use `role="separator"` on a divider row and `role="none"` on
253
+ the section label and action wrappers.
254
+
255
+ ```html
256
+ <menu class="menu" role="menu" aria-label="Account actions">
257
+ <li class="menu-label" role="none">Preferences</li>
258
+ <li role="none"><button class="menu-item" role="menuitem" type="button">Settings</button></li>
259
+ <li class="menu-separator" role="separator"></li>
260
+ <li role="none"><button class="menu-item danger" role="menuitem" type="button">Sign out</button></li>
261
+ </menu>
262
+ ```
263
+
251
264
  ### Linting `role="menu"`
252
265
 
253
266
  Biome's `a11y/noNoninteractiveElementToInteractiveRole` reports
@@ -271,9 +284,14 @@ Until it is fixed upstream, turn the rule off:
271
284
  }
272
285
  ```
273
286
 
274
- One line, and no `biome-ignore` comment above every menu in your markup. The
275
- rest of the `a11y` group stays on and is worth keeping — with just this rule
276
- off, the menu anatomy above lints clean.
287
+ If HTML linting reports the divider row under `a11y/useSemanticElements`,
288
+ suppress the finding on that row. A direct child of `<menu>` must be a list
289
+ row here.
290
+
291
+ ```html
292
+ <!-- biome-ignore lint/a11y/useSemanticElements: A menu divider must be a list row. -->
293
+ <li class="menu-separator" role="separator"></li>
294
+ ```
277
295
 
278
296
  [Accessibility decisions](https://github.com/lekoala/actual-css/blob/master/docs/design-notes/accessibility-decisions.md)
279
297
  records which patterns Biome rejects, and which of its findings were right.
@@ -564,7 +582,7 @@ compete with the menu; keep the trigger button as the discoverable path.
564
582
  hidden>
565
583
  <li><button class="menu-item" type="button">Open</button></li>
566
584
  <li><button class="menu-item" type="button">Rename</button></li>
567
- <hr class="menu-separator">
585
+ <li class="menu-separator" aria-hidden="true"></li>
568
586
  <li><button class="menu-item danger" type="button">Delete</button></li>
569
587
  </menu>
570
588
  </div>
@@ -57,7 +57,7 @@ any labelled set of related objects. Suppress it on the element:
57
57
  ```
58
58
 
59
59
  Unlike the menu rule in
60
- [flyout](../enhancements/flyout.html#linting-rolemenu), do not switch this one
60
+ [flyout](../enhancements/flyout.md#linting-rolemenu), do not switch this one
61
61
  off globally: it correctly catches `<div role="navigation">`,
62
62
  `<div role="button">` and `<div role="separator">`. And drop `role="group"`
63
63
  rather than suppressing it when the wrapper has no label to give — an unnamed
@@ -133,8 +133,10 @@ same optical line. Change the type or the control size and they stay level:
133
133
 
134
134
  ### Hooks
135
135
 
136
- - `--switch-bg` — track fill; `--switch-border` follows it unless overridden.
137
- - `--switch-border` — optional distinct edge; validation takes precedence.
136
+ - `--switch-bg` — track fill.
137
+ - `--switch-border` — track edge. At rest it is `--border-control`, the 3:1 edge
138
+ that identifies the unchecked switch on its surface; checked and disabled
139
+ tracks follow `--switch-bg`. Validation takes precedence.
138
140
 
139
141
  - `--choice-control-size` — shared size for inline choices; the switch track is
140
142
  this plus `0.125em`, so scaling it scales the checkbox and the switch together.
@@ -160,6 +160,9 @@ and help text, and intent colors keep the page palette, which nothing tunes for
160
160
  `--surface-solid`. Focus lines stay readable there: the theme contract keeps
161
161
  `--focus` at 3:1 on `--surface-solid`.
162
162
 
163
+ For a custom background, check the focus line against that background and
164
+ override `--focus` on the panel if the contrast falls below 3:1.
165
+
163
166
  → Foundations · Tokens (theme contract) · Examples · Contrast contexts
164
167
 
165
168
  ### Scope a theme to one section / microtheme / theme island
@@ -126,19 +126,19 @@ Surfaces are painted material and may be translucent. Two roles must stay opaque
126
126
 
127
127
  A theme with translucent surfaces overrides both with opaque values.
128
128
 
129
- `--border` separates surfaces: cards, tables, dividers, panels. `--border-control`
130
- is the resting edge that tells a control apart from the surface — fields,
131
- checkboxes and radios, OTP cells, choice cards, join addons, neutral
132
- outline buttons, the color and file inputs. It is derived from `--text` and
133
- `--surface`; on the default palette it holds 3:1 against `--surface` and
134
- 2.9–3.0 against `--surface-subtle`. `actual-css contrast` reports it for your
135
- theme. `--border-control-mix` sets the ink share; raise it when a tinted or
136
- translucent surface pulls the edge under 3:1. The mix resolves at a theme
137
- boundary: set it on `:root` or a `[data-theme]` island, because a plain container
138
- inherits the colour already resolved above it. Without `color-mix()` it falls
139
- back to `--border`. Set `--border-control` itself to soften or strengthen every
140
- control in a subtree without touching a separator. Hover, checked, invalid and
141
- disabled states keep their own colors.
129
+ `--border` separates surfaces: cards, tables, dividers, panels.
130
+ `--border-control` is the resting edge that tells a control apart from the
131
+ surface — fields, checkboxes and radios, unchecked switches, OTP cells, choice
132
+ cards, join addons, neutral outline buttons, the color and file inputs. It is
133
+ derived from `--text` and `--surface`; on the default palette it holds 3:1
134
+ against `--surface` and 2.9–3.0 against `--surface-subtle`. `actual-css
135
+ contrast` reports it for your theme. `--border-control-mix` sets the ink share;
136
+ raise it when a tinted or translucent surface pulls the edge under 3:1. The mix
137
+ resolves at a theme boundary: set it on `:root` or a `[data-theme]` island,
138
+ because a plain container inherits the colour already resolved above it. Without
139
+ `color-mix()` it falls back to `--border`. Set `--border-control` itself to
140
+ soften or strengthen every control in a subtree without touching a separator.
141
+ Hover, checked, invalid and disabled states keep their own colors.
142
142
 
143
143
  ```css
144
144
  /* Every control in one theme: */
package/llms.txt CHANGED
@@ -36,12 +36,12 @@ named tokens (`tabs`, `flyout`, `range`, `scrollspy`, `in-view`, `validation`,
36
36
  Leaf behaviors whose opt-in also carries configuration use their own attribute
37
37
  (`data-tooltip`, `data-mask`, `data-filter`, `data-context-menu`), and `<dialog>`
38
38
  needs none. See
39
- [when a token, when a data-*](docs/design-notes/enhancement-contract.md).
39
+ [when a token, when a data-*](https://github.com/lekoala/actual-css/blob/master/docs/design-notes/enhancement-contract.md).
40
40
 
41
41
  Behaviour primitives are independently importable for building custom widgets,
42
42
  including `enhance`, `surface`, `floating`, `focus-group`, `keys`, `input`,
43
43
  `command`, `menu`, `focus`, `escape`, and `events`. See
44
- [widget primitives](docs/design-notes/widget-primitives.md).
44
+ [widget primitives](https://github.com/lekoala/actual-css/blob/master/docs/design-notes/widget-primitives.md).
45
45
 
46
46
  ## What the vocabulary does not have
47
47
 
@@ -55,7 +55,7 @@ including `enhance`, `surface`, `floating`, `focus-group`, `keys`, `input`,
55
55
  - Modifiers such as `.ghost`, `.link`, `.flush`, `.raised` only mean something
56
56
  on their component; alone they are inert.
57
57
 
58
- See [naming](docs/design-notes/naming.md) and
58
+ See [naming](https://github.com/lekoala/actual-css/blob/master/docs/design-notes/naming.md) and
59
59
  [utilities non-goals](docs/pages/utilities/overview.md#non-goals).
60
60
 
61
61
  ## Choosing a page shell
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "actual-css",
3
- "version": "0.19.3",
3
+ "version": "0.19.5",
4
4
  "description": "Plain CSS component framework with semantic classes, universal variants, small tokens, theme hooks, and progressive enhancements.",
5
5
  "type": "module",
6
6
  "packageManager": "bun@1.4.4",
@@ -105,12 +105,11 @@
105
105
  "reserved-classes.json",
106
106
  "components.json",
107
107
  "tokens.json",
108
- "docs",
108
+ "docs/pages",
109
+ "docs/brand",
109
110
  "skills",
110
111
  "CHANGELOG.md",
111
- "llms.txt",
112
- "LICENSE",
113
- "README.md"
112
+ "llms.txt"
114
113
  ],
115
114
  "engines": {
116
115
  "bun": ">=1.4.0",
@@ -30,9 +30,9 @@ function usage() {
30
30
  "",
31
31
  "contrast: measure the pairs a theme tunes by hand in headless Chrome, in every",
32
32
  "scheme it declares: soft ink on its resting and hovered fill, the resting edge",
33
- "of a field, checkbox and radio, the focus line on --surface and --surface-solid,",
34
- "the invalid-field focus line, and the inverse text. Exits 1 when a pair misses",
35
- "its threshold. Needs Bun (bunx --bun actual-css contrast ...).",
33
+ "of a field, checkbox, radio and unchecked switch, the focus line on --surface",
34
+ "and --surface-solid, the invalid-field focus line, and the inverse text. Exits 1",
35
+ "when a pair misses its threshold. Needs Bun (bunx --bun actual-css contrast ...).",
36
36
  ].join("\n");
37
37
  }
38
38
 
@@ -3,8 +3,8 @@
3
3
  *
4
4
  * Docs: docs/pages/enhancements/flyout.md
5
5
  *
6
- * Strict anatomy: .menu > li > .menu-item. Separators and section labels
7
- * sit directly under .menu as siblings of <li>.
6
+ * Strict anatomy: .menu > li > .menu-item for actions. Section labels and
7
+ * separators are their own non-interactive <li> rows.
8
8
  *
9
9
  * Public hooks:
10
10
  * --menu-item-icon-size
@@ -30,8 +30,10 @@
30
30
 
31
31
  .switch {
32
32
  --switch-bg: var(--border);
33
- /* Keep the border in the geometry without outlining the track. */
34
- --switch-border: var(--switch-bg);
33
+ /* The quiet --border track does not stand out from the surface: at rest the
34
+ control edge is what identifies the switch (WCAG 1.4.11, 3:1). Checked and
35
+ disabled tracks drop it for a uniform fill. */
36
+ --switch-border: var(--border-control);
35
37
  --switch-knob: var(--surface-raised);
36
38
  --switch-block-size: calc(var(--choice-control-size) + 0.125em);
37
39
  --switch-width: calc(var(--switch-block-size) * 1.8);
@@ -108,6 +110,7 @@
108
110
 
109
111
  .switch:checked {
110
112
  --switch-bg: var(--intent, var(--state-selected));
113
+ --switch-border: var(--switch-bg);
111
114
  --switch-knob: var(--intent-fg, var(--state-selected-fg));
112
115
  }
113
116
 
@@ -138,6 +141,7 @@
138
141
 
139
142
  .switch:disabled {
140
143
  --switch-bg: var(--surface-subtle);
144
+ --switch-border: var(--switch-bg);
141
145
  --switch-knob: var(--state-disabled);
142
146
  opacity: 1;
143
147
  cursor: not-allowed;
package/src/js/dialog.js CHANGED
@@ -35,6 +35,7 @@ import { EVENTS } from "./events.js";
35
35
  import { submissionSetting } from "./form-submission.js";
36
36
  import { afterParse } from "./parsed.js";
37
37
  import { CLASSES } from "./selectors.js";
38
+ import { findFocusSurface, surfaceFocusReturns } from "./surface-focus.js";
38
39
 
39
40
  const dialogMap = new WeakMap();
40
41
  const autoOpened = new WeakSet();
@@ -226,18 +227,24 @@ function canViewTransition(dialog, trigger) {
226
227
  );
227
228
  }
228
229
 
230
+ function dialogFocusReturn(dialog, trigger) {
231
+ const target = trigger || dialog?.ownerDocument?.activeElement;
232
+ return { target, fallback: surfaceFocusReturns.get(findFocusSurface(target)) };
233
+ }
234
+
229
235
  function openDialogWithViewTransition(dialog, trigger, forcedModal = null) {
230
236
  if (!canViewTransition(dialog, trigger)) {
231
237
  openDialog(dialog, trigger, forcedModal);
232
238
  return;
233
239
  }
234
240
 
241
+ const focusReturn = dialogFocusReturn(dialog, trigger);
235
242
  setVtName(trigger, VT_NAME);
236
243
 
237
244
  const transition = dialog.ownerDocument.startViewTransition(() => {
238
245
  clearVtName(trigger);
239
246
  setVtName(dialog, VT_NAME);
240
- openDialog(dialog, trigger, forcedModal);
247
+ showDialog(dialog, focusReturn, forcedModal);
241
248
  });
242
249
 
243
250
  transition.finished.finally(() => clearVtName(dialog, trigger)).catch(() => {});
@@ -291,7 +298,7 @@ export function closeDialog(dialog, returnValue = "") {
291
298
  const state = ensureDelegatedDialog(dialog);
292
299
  if (state.closing) return;
293
300
 
294
- const trigger = state.restoreFocusTo;
301
+ const trigger = state.focusReturn?.target;
295
302
  if (canViewTransition(dialog, trigger)) {
296
303
  state.closing = true;
297
304
  setVtName(dialog, VT_NAME);
@@ -333,6 +340,10 @@ export function requestDialogClose(dialog, returnValue = "") {
333
340
  }
334
341
 
335
342
  export function openDialog(dialog, trigger = null, forcedModal = null) {
343
+ showDialog(dialog, dialogFocusReturn(dialog, trigger), forcedModal);
344
+ }
345
+
346
+ function showDialog(dialog, focusReturn, forcedModal) {
336
347
  if (!isDialogElement(dialog) || dialog.open || !dialog.isConnected) return;
337
348
 
338
349
  const state = ensureDelegatedDialog(dialog);
@@ -340,7 +351,7 @@ export function openDialog(dialog, trigger = null, forcedModal = null) {
340
351
  syncDialogSemantics(dialog, state, modal);
341
352
 
342
353
  state.closing = false;
343
- state.restoreFocusTo = trigger || dialog.ownerDocument.activeElement;
354
+ state.focusReturn = focusReturn;
344
355
 
345
356
  // showModal()/show() focus the dialog, and Chrome resets the viewport scroll
346
357
  // while doing so; capture the position first and restore it so the page does
@@ -408,7 +419,7 @@ function handleDialogSubmit(event) {
408
419
  // formmethod on the submitter wins, as natively: a Save posting from a
409
420
  // method="dialog" form must not close the dialog.
410
421
  if (submissionSetting(form, event.submitter, "method") !== "dialog") return;
411
- if (!canViewTransition(dialog, dialogMap.get(dialog)?.restoreFocusTo)) return;
422
+ if (!canViewTransition(dialog, dialogMap.get(dialog)?.focusReturn?.target)) return;
412
423
 
413
424
  event.preventDefault();
414
425
  closeDialog(dialog, event.submitter?.value || "");
@@ -445,6 +456,16 @@ function handleDialogCancel(event) {
445
456
  closeDialog(dialog, state?.returnValue || "");
446
457
  }
447
458
 
459
+ function restoreFocus(target) {
460
+ if (!target?.isConnected) return false;
461
+ // A closing popover can retain a layout box during its exit transition.
462
+ if (findFocusSurface(target)?.matches(":not(:popover-open)")) return false;
463
+
464
+ const root = target.getRootNode();
465
+ if (root.activeElement !== target) target.focus({ preventScroll: true });
466
+ return root.activeElement === target;
467
+ }
468
+
448
469
  function handleDialogClose(event) {
449
470
  const dialog = event.currentTarget;
450
471
  // close is queued as a task: a dialog closed then reopened in the same task
@@ -467,15 +488,13 @@ function handleDialogClose(event) {
467
488
  state.modalOpen = false;
468
489
  syncModalOpenClass(dialog.ownerDocument);
469
490
 
470
- const restoreFocusTo = state.restoreFocusTo;
471
- state.restoreFocusTo = null;
491
+ const focusReturn = state.focusReturn;
492
+ state.focusReturn = null;
472
493
 
473
494
  // The native dialog restores focus to the previously focused element on
474
495
  // close; only step in when it has not (e.g. an explicit trigger we tracked)
475
496
  // and avoid scrolling the viewport while doing so.
476
- if (restoreFocusTo?.isConnected && dialog.ownerDocument.activeElement !== restoreFocusTo) {
477
- restoreFocusTo.focus({ preventScroll: true });
478
- }
497
+ if (!restoreFocus(focusReturn?.target)) restoreFocus(focusReturn?.fallback);
479
498
  }
480
499
 
481
500
  function ensureDialogWired(dialog) {
@@ -488,7 +507,7 @@ function ensureDialogWired(dialog) {
488
507
  modalOpen: isModalOpen(dialog),
489
508
  ownedAttributes: [],
490
509
  requestingClose: false,
491
- restoreFocusTo: null,
510
+ focusReturn: null,
492
511
  returnValue: "",
493
512
  staticTimer: null,
494
513
  backdropPress: false,
@@ -554,7 +573,7 @@ function autoOpen(dialog) {
554
573
  if (dialog.open) {
555
574
  // No trigger owns this opening: leave focus restoration to the browser,
556
575
  // and do not morph the closing dialog into the previously active element.
557
- dialogMap.get(dialog).restoreFocusTo = null;
576
+ dialogMap.get(dialog).focusReturn = null;
558
577
  autoOpened.add(dialog);
559
578
  }
560
579
  }
@@ -0,0 +1,14 @@
1
+ // Keep the last opener through dismissal so the dialog command can capture
2
+ // it even when the surface's click listener runs first.
3
+ export const surfaceFocusReturns = new WeakMap();
4
+
5
+ export function findFocusSurface(element) {
6
+ for (
7
+ let node = element;
8
+ node;
9
+ node = node.assignedSlot || node.parentElement || node.getRootNode().host
10
+ ) {
11
+ if (surfaceFocusReturns.has(node)) return node;
12
+ }
13
+ return null;
14
+ }
package/src/js/surface.js CHANGED
@@ -5,6 +5,7 @@ import { EVENTS } from "./events.js";
5
5
  import { positionModeFor } from "./floating-space.js";
6
6
 
7
7
  import { CLASSES } from "./selectors.js";
8
+ import { surfaceFocusReturns } from "./surface-focus.js";
8
9
 
9
10
  const openSurfaces = new Set();
10
11
  const surfaceMap = new WeakMap();
@@ -297,7 +298,7 @@ export function openSurface(menu, opts = {}) {
297
298
  state.shift = opts.shift !== false;
298
299
  state.shiftPadding = opts.shiftPadding ?? 4;
299
300
  state.scope = opts.scope;
300
- state.restoreFocusTo = opts.restoreFocusTo || opts.trigger || opts.source || null;
301
+ surfaceFocusReturns.set(menu, opts.restoreFocusTo || opts.trigger || opts.source || null);
301
302
 
302
303
  // Points are client coordinates and therefore always viewport-relative.
303
304
  // Element anchors choose their coupled coordinate/CSS mode once per open;
@@ -313,6 +314,7 @@ export function openSurface(menu, opts = {}) {
313
314
  // Promote before measuring: a closed popover has no box to position.
314
315
  if (!showTransport(menu)) {
315
316
  openSurfaces.delete(menu);
317
+ surfaceFocusReturns.delete(menu);
316
318
  return false;
317
319
  }
318
320
  menu.classList.add(CLASSES.open);
@@ -320,6 +322,7 @@ export function openSurface(menu, opts = {}) {
320
322
 
321
323
  if (!positionSurface(menu)) {
322
324
  closeSurface(menu, { restoreFocus: false });
325
+ surfaceFocusReturns.delete(menu);
323
326
  return false;
324
327
  }
325
328
 
@@ -360,6 +363,7 @@ export function closeSurface(menu, opts = {}) {
360
363
  const state = surfaceMap.get(menu);
361
364
  const activeElement = menu.ownerDocument.activeElement;
362
365
  const shouldRestoreFocus = opts.restoreFocus ?? menu.contains(activeElement);
366
+ const restoreFocusTo = surfaceFocusReturns.get(menu);
363
367
  menu.classList.remove(CLASSES.open);
364
368
  hideTransport(menu);
365
369
  openSurfaces.delete(menu);
@@ -368,14 +372,15 @@ export function closeSurface(menu, opts = {}) {
368
372
  state?.stopScrollIntent?.();
369
373
  state?.stopTracking?.();
370
374
 
371
- if (shouldRestoreFocus && state?.restoreFocusTo?.isConnected) {
372
- state.restoreFocusTo.focus({ preventScroll: true });
375
+ if (shouldRestoreFocus && restoreFocusTo?.isConnected) {
376
+ restoreFocusTo.focus({ preventScroll: true });
373
377
  }
374
378
  }
375
379
 
376
380
  export function disconnectSurface(menu) {
377
381
  if (!menu) return;
378
382
  closeSurface(menu);
383
+ surfaceFocusReturns.delete(menu);
379
384
  menu.removeEventListener(EVENTS.dismiss, onSurfaceDismiss);
380
385
  const state = surfaceMap.get(menu);
381
386
  if (state) {
@@ -5,7 +5,8 @@
5
5
  * (`bun run report:theme-contrast`).
6
6
  *
7
7
  * Measured per island (one per color scheme the theme declares):
8
- * - the resting edge of a field, checkbox and radio against --surface (3:1)
8
+ * - the resting edge of a field, checkbox, radio and unchecked switch against
9
+ * --surface (3:1)
9
10
  * - soft ink against the resting and the hovered soft fill (4.5:1), on each
10
11
  * surface a soft element sits on
11
12
  * - the solid pairs, -fg on the intent fill (4.5:1); a fill painted by a
@@ -73,11 +74,14 @@ function islandMarkup(id, scheme) {
73
74
 
74
75
  /* Controls whose resting edge is all that identifies them (WCAG 1.4.11): the
75
76
  edge against the surface around them needs 3:1. The field is read on its
76
- block-end side, the one an underline-only theme (material) keeps. */
77
+ block-end side, the one an underline-only theme (material) keeps. An
78
+ unchecked switch is one of them: its track fill is a quiet --border, so the
79
+ edge is what tells it apart from the surface. */
77
80
  export const CONTROLS = [
78
81
  ["field", '<input class="input">'],
79
82
  ["checkbox", '<input class="check" type="checkbox">'],
80
83
  ["radio", '<input class="radio" type="radio">'],
84
+ ["switch", '<input class="switch" type="checkbox" role="switch">'],
81
85
  ];
82
86
 
83
87
  const ratio = (fg, bg) => (fg[3] < 255 || bg[3] < 255 ? null : contrast(fg, bg));
@@ -1,65 +0,0 @@
1
- # Accessibility decisions
2
-
3
- ## Guarantees
4
-
5
- Actual CSS makes the accessible path the default where CSS and small runtime enhancers can help.
6
-
7
- - Visible `:focus-visible` styles on interactive components.
8
- - Native elements first: `button`, `a`, `details`, `dialog`, form controls.
9
- - Reduced motion support through shared duration tokens and the reset.
10
- - Forced-colors support on controls and visual state indicators.
11
- - DOM tests for enhancer lifecycle, focus, attributes, and keyboard behavior.
12
-
13
- ## Linters that reject ARIA patterns
14
-
15
- Measured on Biome 2.5.6, in HTML and JSX alike.
16
-
17
- `a11y/noNoninteractiveElementToInteractiveRole` reports `<menu role="menu">`,
18
- and its fix removes the role, which dismantles the composite. It is a port of
19
- `jsx-a11y/no-noninteractive-element-to-interactive-role` that dropped the source
20
- rule's default allowlist, so every ARIA composite built on a list is reported —
21
- `menu`, `listbox`, `tablist`, `menubar`, `tree`, `grid` — even though the source
22
- documents `<ul role="menu">` as valid. Switch the rule off; a per-element
23
- suppression would sit above every menu in the markup.
24
-
25
- `a11y/useSemanticElements` reports `role="group"` on `.join` and
26
- `.avatar-stack`, suggesting `<fieldset>`. `<fieldset>` groups form controls
27
- under a `<legend>`; ARIA's `group` is any labelled set of related objects. This
28
- rule stays on — it correctly catches `<div role="navigation">`,
29
- `<div role="button">`, `<div role="separator">` — so suppress it on the wrapper
30
- instead. A wrapper with no label to give should drop the role rather than
31
- suppress the rule.
32
-
33
- Two decisions these findings settled:
34
-
35
- - `.join` keeps `role="group"` rather than `role="toolbar"`, which the rule does
36
- not report. Toolbar owes arrow-key navigation with a roving tabindex, and
37
- claiming the role without the behaviour is worse than the false positive.
38
- - `.menu-separator` is a plain `<hr>`. The `role="separator"` these docs used to
39
- show is implied by the element, and `a11y/noRedundantRoles` was right to
40
- reject it. Nothing in the CSS or the runtime read it.
41
-
42
- Only the menu container is ever reported: `role="menuitem"` sits on a `<button>`
43
- or `<a>`, never on the `<li>`, and an interactive element is a legitimate role
44
- host. Tabs put `role="tablist"` on a `<div>`, so they are unaffected.
45
-
46
- ## Author Responsibilities
47
-
48
- - Name icon-only buttons.
49
- - Use the ARIA attributes shown in examples.
50
- - Keep form errors inline and connected with `aria-describedby`.
51
- - Do not put critical information only in a transient notification.
52
-
53
- ## Interactive states
54
-
55
- - Interactive controls must be identifiable at rest, either by their own styling or by clear surrounding context.
56
- - Interactive states are: rest, hover, active / pressed, focus-visible, disabled, selected / current / expanded (when applicable).
57
- - Do not rely on hover alone to reveal interactivity.
58
- - Do not use color alone to communicate state.
59
- - Use structure, border, background, iconography, and spacing consistently.
60
- - Select controls stay quieter than text inputs: hover uses a subtle surface change, while focus-visible and open states use a soft ring in normal color modes.
61
- - Forced-colors keeps strong outlines for select focus/open states, high-contrast option hover/focus states, and a selected checkmark that inherits the option text color unless the option is highlighted.
62
- - Global Escape handlers only prevent default when Actual has a visible managed surface to close.
63
- - Prefer explicit `data-filter` values in examples and docs. Empty `data-filter`
64
- does not infer behavior from `inputmode`: keyboard hints and destructive value
65
- filtering remain separate contracts.