Repository navigation
fix(ui): run a closing palette command's onAction after the close - #446
Merged
Merged
Conversation
Member
Author
|
Added a commit that keeps the palette within a stated asset budget. The deferred onAction pushed the complete Command Palette JavaScript to 21427 bytes gzip and 18256 Brotli, past the 20 KiB and 17 KiB limits; main had 91 and 55 bytes of headroom. Shortening the new JS comments brought it to 21030 and 17945. The rest is logic (about 2.3 KiB raw), so the limits rise to 21.5 KiB gzip and 18.5 KiB Brotli, with the reason in the test and in the design doc's budget table. Locally all non-e2e citry_ui tests pass (3262), and so do the palette e2e tests in Chromium and Firefox. The separate Python 3.15 gzip-level failure in the same test is fixed in #449. |
CCommandPalette called onAction before it closed, while the modal still made the rest of the page inert, so an owner's focus() in onAction did nothing. A command that closes the palette now closes it first (after onOpenChange(false) and the query reset) and then calls onAction. A command that keeps the palette open still calls onAction right away. - An uncontrolled close applies at once, so onAction still runs inside the user's event, even if the owner reopened the palette in onOpenChange(false). - In controlled mode the palette runs onAction one microtask after onOpenChange, outside the palette's reactive effect. When the owner set open=false synchronously inside onOpenChange, Vue's update has applied the close by then. Whatever the owner did (accepted, kept open=true, accepted only later, or released control), onAction runs there and does not wait for a later close; an owner that closes later gets it while the palette is still open. - If an owner callback throws during the close, the error propagates (or Vue reports it, for an error thrown during its update) and onAction still runs: at once when uncontrolled, one microtask later when controlled. - If the palette is cleaned up first, for example when the owner unmounts it while closing it, onAction runs in a microtask after the cleanup. - An earlier command still waiting runs before the next chosen one. - A throw in onAction is reported through reportError; the palette does not reopen. To keep the palette open, set close_on_action=False. api.md, api.yml, the example, the design doc and the citry_ui CHANGELOG (a Breaking entry) describe the new order. E2E tests cover the order in both modes, the declined close, the owner releasing control or reopening the palette, owner callback throws in both modes, the unmount, the reactive tracking, owner focus in both modes, and a clipboard write after the deferral; they run in Chromium and Firefox. Probe tests for owner focus in CContextMenu, CDialog, CAlertDialog, CDrawer and CPopover keep the passing cases as regression tests and mark the controlled-dialog and popover outside-click losses as strict xfails for #442. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…dget The deferred onAction from the previous commit grew the complete Command Palette JavaScript past its 20 KiB gzip and 17 KiB Brotli budgets; on main the family had under 0.1 KiB of headroom. Shortening the new comments recovered about 0.4 KiB gzip, and the rest is logic: about 2.3 KiB raw (0.6 KiB gzip) for running a closing command's onAction after the close, with its handling of owner errors, reopening and unmounting. The gzip and Brotli limits rise by 1.5 KiB, to 21.5 KiB and 18.5 KiB, with the reason recorded beside the test and in the design doc's budget table. Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec
force-pushed
the
fix/ui-palette-action-after-close
branch
from
October 27, 2026 16:58
25889c4 to
e58dd10
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #420.
What this fixes
CCommandPalette called
onActionbefore it closed. At that point the modal still made the rest of the page inert, so afocus()call from the owner inonActiondid nothing. Now a command that closes the palette closes it first: the palette callsonOpenChange(false), resets the query, and only then callsonAction. A command that keeps the palette open still callsonActionright away.How the timing works
onActionruns inside the user's event. This holds even when the owner'sonOpenChange(false)reopens the palette.onActionone microtask afteronOpenChangereturns, outside its own reactive effect. If the owner setopen=falsesynchronously insideonOpenChange, Vue's update has already applied the close by then. An owner that closes later, for example after anawait, innextTickor in a.then(), getsonActionwhile the palette is still open. api.md says so.onActionexactly once and never on a later close. That includes an owner callback that throws during the close, an owner that releases control withopen=null, and an owner that unmounts the palette while closing it (onActionthen runs in a microtask after the cleanup).onActionis reported throughreportError, and the palette does not reopen. To keep the palette open after a command, setclose_on_action=False.This is a Breaking entry in the citry_ui CHANGELOG. api.md, api.yml, the example and docs/design/ui_components/command-palette.md are updated to match.
Other popups
I probed whether an owner's
focus()in a close callback survives in the other popups. CContextMenu keeps it in all six cases tested. It is lost in controlled CDialog, CAlertDialog and CDrawer, and on a CPopover outside click. Neither is the same small change as this one, so both are filed as #442. Their probe tests are strict xfails (raises=AssertionError) that reference #442, and the passing cases stay as regression tests.Left out on purpose
onQueryChange, and theonOpenChangecall when the palette becomes disabled, still run inside the palette's reactive effect, so anything they read is tracked. That is how main behaves today; this PR only movesonActionout of the effect.Evidence
clipboard.writeText, and the deferred write still succeeds there in both modes, for both click and Enter.scripts/validate.py, ruff, and the citry_ui contract tests pass.🤖 Generated with Claude Code