fix(sidebar): fix rename input losing its selection on open#5563
Conversation
Radix's FocusScope defers close-time focus teardown to a setTimeout(0), which can occasionally run after the rename input's own focus()/select() and clobber the selection. Focus the input from onCloseAutoFocus instead, which runs inside that same deferred teardown and always wins the race. Affects workflow, folder, and workspace rename (all route through the shared sidebar ContextMenu component).
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview The shared Ref wiring is limited to workflow, folder, and workspace rename call sites; other Reviewed by Cursor Bugbot for commit 26f4482. Configure here. |
Greptile SummaryThis PR fixes the sidebar rename focus race. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (3): Last reviewed commit: "fix(sidebar): only refocus the rename in..." | Re-trigger Greptile |
… close onCloseAutoFocus fires on every menu close, not just after selecting Rename. Gate the refocus behind a ref set only when the Rename item was selected, so closing the menu for an unrelated action (Delete, Duplicate, ...) while an earlier rename is still live doesn't steal focus back into it and delay its blur-save.
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 26f4482. Configure here.
|
@greptile review |
Summary
FocusScopedefers its close-time focus teardown to asetTimeout(0), which can run after the rename input's own mount-timefocus()/select()and clobber the selection — explains why it was intermittent rather than every timeContextMenu'sonCloseAutoFocushandler instead of a plain effect, since that callback runs synchronously inside Radix's own deferred teardown and always wins the race regardless of scheduler timingrenameInputRefprop onContextMenu, wired from the three rename call sites) — every otherContextMenuconsumer is unaffectedType of Change
Testing
Verified via typecheck (clean, no new errors) and lint (clean), and traced the fix against Radix's actual FocusScope source to confirm the timing race it closes. Could not click through the live repro in this environment (no DB/auth available locally) — worth a manual pass before merge.
Checklist