Skip to content

fix: redirect focus to list's domNode when removing focused row to prevent focus loss#302618

Draft
TylerLeonhardt wants to merge 1 commit intomainfrom
tyler/parallel-leech
Draft

fix: redirect focus to list's domNode when removing focused row to prevent focus loss#302618
TylerLeonhardt wants to merge 1 commit intomainfrom
tyler/parallel-leech

Conversation

@TylerLeonhardt
Copy link
Member

Steps:

  1. workbench.quickOpen.closeOnFocusLost MUST be true (it's the default)
  2. click checkbox in a quick pick or quick tree
  3. scroll that checkbox off the screen
  4. 🐛 quick thing closes

I also repro this when the action bar on the right is focused in a quick pick so it's not specific to checkboxes.

This is because:

  1. list widget kills the entry in the list (and the children, checkboxes, action bars, whatever)
  2. checkboxes and action bars then blur() to the root element of vscode
  3. quick pick reacts to being blurred (focused out) and closes itself

This is probably not the right fix, but I want something like this... I'll make a similar fix catered to just the quick pick so that the issue can be resolved but @joaomoreno lmk if you have any ideas.

#289980

…event focus loss

Steps:
1. `workbench.quickOpen.closeOnFocusLost` MUST be true (it's the default)
1. click checkbox in a quick pick or quick tree
1. scroll that checkbox off the screen
1. 🐛 quick thing closes

I also repro this when the action bar on the right is focused in a quick pick so it's not specific to checkboxes.

This is because:
1. list widget kills the entry in the list (and the children, checkboxes, action bars, whatever)
2. checkboxes and action bars then `blur()` to the root element of vscode
3. quick pick reacts to being blurred (focused out) and closes itself

This is probably not the right fix, but I want something like this... I'll make a similar fix catered to just the quick pick so that the issue can be resolved but @joaomoreno lmk if you have any ideas.

#289980
Copilot AI review requested due to automatic review settings March 18, 2026 00:45
@TylerLeonhardt TylerLeonhardt self-assigned this Mar 18, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Prevents focus from escaping the base ListView widget when a focused row is recycled/removed (e.g., during scrolling), which can otherwise trigger closeOnFocusLost behavior in Quick Pick–style UIs.

Changes:

  • Detects when the active element is inside a row that is about to be removed.
  • Redirects focus back to the list container to avoid “focus loss” to the workbench/root.

You can also share your feedback on Copilot code review. Take the survey.

// to be recycled, which would otherwise blur the whole quick pick).
const activeElement = getActiveElement();
if (activeElement && isAncestor(activeElement, item.row.domNode)) {
this.domNode.focus();
// If the row being removed contains the currently focused element,
// redirect focus to the list's domNode to prevent focus from escaping
// the widget entirely (e.g. when scrolling causes a focused checkbox
// to be recycled, which would otherwise blur the whole quick pick).
// to be recycled, which would otherwise blur the whole quick pick).
const activeElement = getActiveElement();
if (activeElement && isAncestor(activeElement, item.row.domNode)) {
this.domNode.focus();
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.

2 participants