Skip to content

fix(dialog): keyboard opens and Esc closes skip motion through createSkipMotion - #163

Merged
aayushbtw merged 3 commits into
ui-sdkfrom
fix/keyboard-skip-motion
Nov 21, 2026
Merged

aayushbtw merged 3 commits into
ui-sdkfrom
fix/keyboard-skip-motion

Conversation

@aayushbtw

Copy link
Copy Markdown
Owner

Why

Goal of this run: fix every bug on ui-sdk that we can fix on our side, so it can land on main with no known issues. This PR fixes #47 and #64. DESIGN.md's never-list bans motion on a keyboard action. Dialog, Alert Dialog and Side Panel faded and scaled on a keyboard open and on Esc, the same as a pointer open, because their roots never recorded how a change came about.

What

  • createSkipMotion() in lib/constella/motion.tsx (renamed from .ts for JSX) gives each popup family one root wrapper and one hook that its parts read for data-skip-motion. Select, Combobox, Dropdown Menu (submenu with inherit) and Popover drop their copied SkipMotion contexts and use it.
  • Dialog, Alert Dialog, Side Panel and Command Dialog share one instance from dialog.tsx. Command Dialog wraps ui-sdk's Dialog root, not ours, so it keeps one skip state with its own skipsDialogMotion.
  • A finished close (onOpenChangeComplete(false)) clears the skip. Without it, a controlled Dialog reopened by pointer after an Esc close opened at once (measured).
  • Side Panel's motion moves into popupMotion.sidePanel, with the skip guard on its starting style. popupMotion.dialog zeroes its duration only during its own open or close, so the nested step-back still moves.
  • Tests: motion.css.test.tsx gains Alert Dialog and Side Panel rows. The Side Panel row failed first (commit 8a1ec52). New motion.test.tsx pins the helper: keyboard skip, pointer animates, custom skips, inherit, and the reset. Three pick tests now check the skip while the close runs, since it clears afterward.
  • Docs: ARCHITECTURE.md (Dialog, Sheet and Motion rows) and docs/design/components.md.

Verification

Chromium, static build, real key presses, per-frame computed opacity and translate. Script: ~/.local/share/pw/skm-proof.mjs.

Row Before: Enter / Esc After: Enter / Esc Pointer open / close
Dialog animates / animates instant / instant animates / animates
Alert Dialog animates / animates instant / instant animates / animates
Side Panel animates / instant instant / instant animates / instant (by design)
Command Dialog instant / instant instant / instant animates / animates
Popover, Select, Dropdown Menu, Combobox instant / instant instant / instant animates / animates
Sheet animates / animates animates / animates animates / animates

Edge cases (skm-edge.mjs, on a VITE_AGENT_BRIDGE=1 build). A controlled Dialog reopened by pointer after Esc animates. Enter on Alert Dialog's Cancel closes at once. A keyboard submenu opens and closes at once. The agent confirm opened by confirmController.open() animates, and Enter, Esc and a reopen behave the same. Pointer Allow animates. No console errors, so no skipped flushSync.

vpr check, vpr test (555 passed) and vpr build pass on 36dbaaa. Reuse reviewer verdict: CLEAN. Frame dumps, screenshots (light and dark, opened by keyboard) and the verdict are in the run's shots/A-motion/.

Tradeoffs

  • Sheet and Sidebar's mobile Sheet still slide on a keyboard open or Esc. ui-sdk's Drawer runs its spring for every open except an initial one and has no instant close. A near-zero physics.response would fake it, but that is a workaround, so it's out. This needs an upstream option.
  • A render-prop root was chosen over a HOC, because Select and Combobox are generic roots and a HOC drops their type parameters.
  • Fix Root Causes: every root records the change's source, so CSS guards alone don't paper over the missing state. Side Panel joins popupMotion, the same bug class as fix(popup): share popupMotion, so an instant open never paints offstage #132.
  • Migrate Callers Then Delete Legacy APIs: all four copied contexts move to createSkipMotion in this PR. None is left behind.
  • A nested dialog opened from the keyboard still steps its parent back with motion, the same as before.

Tracker

…open paints offstage

Side Panel's entering style has no skip-motion guard (#64), so its row fails until the fix.
…SkipMotion

Dialog, Alert Dialog and Side Panel roots never tracked how they opened, so a
keyboard open or Esc close faded and scaled like a pointer one (#47, #64).

createSkipMotion gives each popup family one root wrapper and one part hook.
Dialog, Alert Dialog, Side Panel and Command Dialog share the dialog instance;
Select, Combobox, Dropdown Menu and Popover drop their copied context. A
finished close clears the skip, so a controlled reopen by pointer animates.
Side Panel's motion moves into popupMotion with a skip guard.

Sheet still slides: ui-sdk Drawer has no instant open or close.

Refs #47, #64
@aayushbtw

Copy link
Copy Markdown
Owner Author

Verifier: PASS+NOTES on merge tree 123983c9 (ui-sdk 6be0088 + head 36dbaaa). check, build, 560 tests. Browser, real keys, 45 frames per step: Dialog, Alert Dialog, Side Panel, Command Dialog open and close instantly from the keyboard; pointer still animates; the 4 migrated popups match base; no skip state leaks; 0 console errors. Notes: tracker rows #47/#64 updated in the lead's docs commit; Sheet still slides (ui-sdk Drawer, upstream).

@aayushbtw
aayushbtw merged commit 3a370ab into ui-sdk Nov 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant