okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-clean-3 (321794636): docs and history (cleanup step 3, items 3.0-3.10); release manifest and capability table with checks, history/ with pointers, link check, tools/ split, bench index; owner OK'd the wording 11-082b36e8a02

main
6.1 KiB118 linesraw

13 · Overlays — drawers, menus, selects, popovers

Files SamplingDrawer.tsx, Sidebar.tsx (More menu), ui.tsx (Select), TelemetryPopover.tsx, Shortcuts.tsx

The surfaces that float above content. All were converted to the same pattern last round: stays mounted, driven by data-open, animates both ways, portals out of any glass ancestor.

What they are today

SurfaceContainerMaterialDismissal
Sampling drawer.st-drawer.sheetregularEsc, scrim, Close
More menu.menuregularclick-away, Esc
Select popup.select__popregularselect, click-away, Esc, scroll
Telemetry popover.telepopregularclick-away, Esc, scroll
Shortcuts dialog.modalopaque + specularEsc, scrim
Command palette.modalopaque + specularEsc, scrim

Every one is portalled where it could otherwise nest inside glass, and npm run luminance fails the build if that ever regresses.

Where it falls short

  1. Six overlay types, three different dismissal grammars. Measured, and documented here. The plan guessed at two grammars; there are three, and the third is the interesting one.

    OverlayEscapeOutside clickScroll
    Command paletteclosesclosesstays
    Shortcutsclosesclosesstays
    Sampling drawercloses—stays
    Telemetry popoverclosesclosescloses
    Select popupclosesclosesrepositions
    Menus (More, session)closesclosesstays

    The rule beneath it: an overlay anchored to content follows or leaves with that content; one that is not anchored ignores scrolling. A telemetry popover is a readout of a row that has just scrolled away, so it closes. A Select is a control you are mid-interaction with, so it moves with its trigger rather than discarding your place. Modals are not anchored to anything, so scroll is none of their business.

    Measuring this took three attempts, and the first two were wrong. Both reported "scroll: stays" for every overlay — because the transcript was already scrolled to its maximum, so scrollTop += 80 clamped to no movement and no scroll event ever fired. A test that asserts nothing happened, when nothing was attempted, is the most convincing kind of wrong.

  2. None of them trap focus. Wrong — they all do. Measured against the visible overlay: the palette, the shortcuts dialog and the sampling drawer each land focus inside on open and keep it there across 18 Tab presses. useSurfaceFocus has done this since the first pass; the plan asserted the opposite without testing. (Testing this needs care: querying .modal finds the hidden palette rather than the open dialog, which is how the claim survived — an early probe of mine "confirmed" the bug the same wrong way.)

  3. The Select popup is the only one without a visible focus ring on its active option when driven by keyboard — data-active sets a background, which is the same treatment as hover.

  4. No overlay is repositioned on resize except the Select, which repositions on scroll and resize.

  5. Escape precedence is implemented in two places — the App key handler and each overlay — with the ordering implicit rather than stated.

  6. Toasts have no tray. Fixed. The stack caps at three — further toasts displace the oldest rather than pushing everything off-screen — and a hovered or focused toast has its dismissal clock stopped and restarted on leave, so reading one does not race its own timer. Verified: five pushes leave three on screen, and a hovered toast is still alive at 6.3 s against a 5.2 s timer.

  7. No overlay announces itself beyond role="dialog"; none uses aria-modal with a labelled heading consistently.

The plan

Substance — one grammar, written down

  1. Document the dismissal rules in the interaction guidelines: transient anchored surfaces (menu, select, popover) close on scroll; modal surfaces do not; everything closes on Escape and click-away. Then verify it.
  2. Focus management for every modal surface: focus moves into the surface on open, is trapped while open, and returns to the invoking control on close. The Select already returns focus; the rest do not trap.
  3. A visible keyboard focus ring inside listbox popups, distinct from the hover background — hover and keyboard selection must not look identical.
  4. Centralise Escape precedence: overlay stack first, then focus mode, then nothing. One place decides, and the rule is stated in the guidelines.
  5. Toasts gain pause-on-hover and a stack cap. Done. The oldest is dropped rather than collapsed into a count — a counter the user cannot open is not worth the space it takes.

Fluidity

  1. Every anchored surface grows from its anchor rather than the window edge — transform-origin set from the trigger's position, so a menu from the bottom bar opens upward from that bar.
  2. Exit animations for modals. Already correct. Measured: on Escape the modal passes through opacity 0.35 at 90 ms before settling at 0 with visibility: hidden. The plan asserted they "cut out" without checking; because they stay mounted and are driven by data-open, the discrete visibility transition gives them a real exit already.

Motion

SurfaceEnterExit
Drawerslide 20 px + fade, --st-t-localreverse, interruptible
Menu / popover6 px lift + fade, --st-t-controlreverse
Select popup4 px lift + fade, --st-t-controlfade only
Modalscale .98 + fade, --st-t-localcurrently instant — needs a reverse
Toast10 px lift, --st-t-local6 px, --st-t-control

All collapse to opacity-only under reduced motion.

Verification

  • New flow overlays2: opens each surface, asserts focus lands inside, tabs past the last control and asserts focus stays trapped, then closes and asserts focus returns to the trigger.
  • Assert no anchored surface overflows the viewport at 900 px — the telemetry popover clamp is the model to copy.
1# 13 · Overlays — drawers, menus, selects, popovers
2
3**Files** `SamplingDrawer.tsx`, `Sidebar.tsx` (More menu), `ui.tsx` (Select),
4`TelemetryPopover.tsx`, `Shortcuts.tsx`
5
6The surfaces that float above content. All were converted to the same pattern
7last round: **stays mounted, driven by `data-open`, animates both ways, portals
8out of any glass ancestor**.
9
10## What they are today
11
12| Surface | Container | Material | Dismissal |
13|---|---|---|---|
14| Sampling drawer | `.st-drawer.sheet` | regular | Esc, scrim, Close |
15| More menu | `.menu` | regular | click-away, Esc |
16| Select popup | `.select__pop` | regular | select, click-away, Esc, scroll |
17| Telemetry popover | `.telepop` | regular | click-away, Esc, scroll |
18| Shortcuts dialog | `.modal` | opaque + specular | Esc, scrim |
19| Command palette | `.modal` | opaque + specular | Esc, scrim |
20
21Every one is portalled where it could otherwise nest inside glass, and
22`npm run luminance` fails the build if that ever regresses.
23
24## Where it falls short
25
261. ~~Six overlay types, three different dismissal grammars.~~ **Measured, and
27   documented here.** The plan guessed at two grammars; there are three, and the
28   third is the interesting one.
29
30   | Overlay | Escape | Outside click | Scroll |
31   |---|---|---|---|
32   | Command palette | closes | closes | stays |
33   | Shortcuts | closes | closes | stays |
34   | Sampling drawer | closes | — | stays |
35   | Telemetry popover | closes | closes | **closes** |
36   | Select popup | closes | closes | **repositions** |
37   | Menus (More, session) | closes | closes | stays |
38
39   The rule beneath it: **an overlay anchored to content follows or leaves with
40   that content; one that is not anchored ignores scrolling.** A telemetry
41   popover is a readout of a row that has just scrolled away, so it closes. A
42   Select is a control you are mid-interaction with, so it moves with its trigger
43   rather than discarding your place. Modals are not anchored to anything, so
44   scroll is none of their business.
45
46   **Measuring this took three attempts, and the first two were wrong.** Both
47   reported "scroll: stays" for every overlay — because the transcript was
48   already scrolled to its maximum, so `scrollTop += 80` clamped to no movement
49   and no scroll event ever fired. A test that asserts nothing happened, when
50   nothing was attempted, is the most convincing kind of wrong.
512. ~~None of them trap focus.~~ **Wrong — they all do.** Measured against the
52   *visible* overlay: the palette, the shortcuts dialog and the sampling drawer
53   each land focus inside on open and keep it there across 18 Tab presses.
54   `useSurfaceFocus` has done this since the first pass; the plan asserted the
55   opposite without testing. (Testing this needs care: querying `.modal` finds
56   the hidden palette rather than the open dialog, which is how the claim
57   survived — an early probe of mine "confirmed" the bug the same wrong way.)
583. **The Select popup is the only one without a visible focus ring on its active
59   option** when driven by keyboard — `data-active` sets a background, which is
60   the same treatment as hover.
614. **No overlay is repositioned on resize** except the Select, which repositions
62   on scroll and resize.
635. **Escape precedence is implemented in two places** — the App key handler and
64   each overlay — with the ordering implicit rather than stated.
656. ~~Toasts have no tray.~~ **Fixed.** The stack caps at three — further toasts
66   displace the oldest rather than pushing everything off-screen — and a hovered
67   or focused toast has its dismissal clock stopped and restarted on leave, so
68   reading one does not race its own timer. Verified: five pushes leave three on
69   screen, and a hovered toast is still alive at 6.3 s against a 5.2 s timer.
707. **No overlay announces itself** beyond `role="dialog"`; none uses
71   `aria-modal` with a labelled heading consistently.
72
73## The plan
74
75### Substance — one grammar, written down
761. **Document the dismissal rules** in the interaction guidelines: *transient
77   anchored surfaces (menu, select, popover) close on scroll; modal surfaces do
78   not; everything closes on Escape and click-away.* Then verify it.
792. **Focus management for every modal surface**: focus moves into the surface on
80   open, is trapped while open, and returns to the invoking control on close. The
81   `Select` already returns focus; the rest do not trap.
823. **A visible keyboard focus ring** inside listbox popups, distinct from the
83   hover background — hover and keyboard selection must not look identical.
844. **Centralise Escape precedence**: overlay stack first, then focus mode, then
85   nothing. One place decides, and the rule is stated in the guidelines.
865. ~~Toasts gain pause-on-hover and a stack cap.~~ **Done.** The oldest is
87   dropped rather than collapsed into a count — a counter the user cannot open is
88   not worth the space it takes.
89
90### Fluidity
916. **Every anchored surface grows from its anchor** rather than the window edge —
92   `transform-origin` set from the trigger's position, so a menu from the bottom
93   bar opens upward *from that bar*.
947. ~~Exit animations for modals.~~ **Already correct.** Measured: on `Escape` the
95   modal passes through opacity **0.35** at 90 ms before settling at 0 with
96   `visibility: hidden`. The plan asserted they "cut out" without checking;
97   because they stay mounted and are driven by `data-open`, the discrete
98   visibility transition gives them a real exit already.
99
100## Motion
101
102| Surface | Enter | Exit |
103|---|---|---|
104| Drawer | slide 20 px + fade, `--st-t-local` | reverse, interruptible |
105| Menu / popover | 6 px lift + fade, `--st-t-control` | reverse |
106| Select popup | 4 px lift + fade, `--st-t-control` | fade only |
107| Modal | scale .98 + fade, `--st-t-local` | currently instant — needs a reverse |
108| Toast | 10 px lift, `--st-t-local` | 6 px, `--st-t-control` |
109
110All collapse to opacity-only under reduced motion.
111
112## Verification
113
114- New `flow overlays2`: opens each surface, asserts focus lands inside, tabs
115  past the last control and asserts focus stays trapped, then closes and asserts
116  focus returns to the trigger.
117- Assert no anchored surface overflows the viewport at 900 px — the telemetry
118  popover clamp is the model to copy.