You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CCommandPalette: an owner's focus move in onAction is lost when the command closes the palette #420
The CCommandPalette API page says that when onAction(value, detail) deliberately moves focus, "that connected focus destination wins over Dialog return-focus behavior" (ccommand_palette/api.md, "Choose action and close policy"). When the chosen command also closes the palette, focus ends up on <body> instead.
Reproduce
Use the command_actions snippet (packages/py/citry_ui/citry_ui/components/ccommand_palette/snippets/command_actions.py), shown on the Command Palette docs page.
Tick Move owner focus. The snippet's onAction then calls $refs.focusTarget.focus() on the "Owner focus target" button.
Open the palette and choose a command that closes it. Use any command without close_on_action=False; the default is to close.
Check document.activeElement.
Expected: the "Owner focus target" button. Actual:BODY.
Why
onAction runs synchronously before the close. While the palette's modal is open, the rest of the page is inert, so the owner's focus() call reaches a button that cannot take focus yet. The close then runs, and no focus move is left to apply.
Likely fix
Record the owner's focus request made during onAction, and apply it once the modal has closed and the target is no longer inert. If the owner moved focus, skip the usual return-focus step. CDialog, CAlertDialog, CDrawer and CPopover need checking for the same ordering problem, wherever an owner callback that runs while the layer is open moves focus outside it.
Activity
fix(ui): run a closing palette command's onAction after the close (#420)