Repository navigation
dock: Hand the focus to the tab that replaces a closed one - #3409
Merged
Merged
Conversation
Closing the focused tab, by its close button, the Close menu item, or `DockArea::remove_panel`, slides a neighbour into its place but leaves the window's focus on the panel that has just gone. Nothing is focused afterwards, so the next keystroke, including another close shortcut, lands nowhere until the user clicks into the dock. When the removed panel held the focus, the panel its group now displays takes it over. Closing a tab that did not have the focus leaves the focus where it is. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DHBYT8JhqczL6GhYZoKgww
huacnlee
previously approved these changes
Oct 8, 2026
huacnlee
left a comment
Member
There was a problem hiding this comment.
Reviewed the focus handoff and regression coverage. The fallback preserves focus chosen by on_removed, handles removal of an entire tab group, and skips hidden panels. All 9 Dock UI tests, relevant Clippy checks, and formatting checks passed.
huacnlee
enabled auto-merge (squash)
October 8, 2026 06:50
huacnlee
disabled auto-merge
October 8, 2026 06:50
huacnlee
enabled auto-merge (squash)
October 8, 2026 06:50
linruohan
pushed a commit
to linruohan/gpui-component
that referenced
this pull request
Oct 9, 2026
…e#3409) Closing a tab steals keyboard focus into nowhere: `DockArea` drops the panel, but the keystroke that follows lands on no view at all. If the closed panel held focus, the panel its group displays in its place should take it over. This change makes `DockArea::remove_panel` check, before removing, whether the panel being closed contains the focused view. If it did, the panel the group now shows in its place (via `active_panel`) is focused. Closing a tab that never had focus changes nothing. Two tests cover both sides: - `dock_hands_the_focus_to_the_tab_that_replaces_a_closed_one` — closing the focused tab moves focus to the newly visible tab. - `dock_leaves_the_focus_alone_when_a_tab_without_it_closes` — closing a background tab leaves focus where it was. No public API changes; behavior-only fix. --- This PR is 100% AI-generated: originally drafted with Claude on 2026-10-04, rebased onto current main, reviewed and validated by the contributor: `cargo fmt --check`, `cargo clippy -p gpui-base --all-targets -- --deny warnings`, and the dock test suite (4 passed, including the two new focus tests) are all green. --------- Co-authored-by: Sola <sola-ryu@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: Jason Lee <huacnlee@gmail.com>
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.
Closing a tab steals keyboard focus into nowhere:
DockAreadrops the panel, but the keystroke that follows lands on no view at all. If the closed panel held focus, the panel its group displays in its place should take it over.This change makes
DockArea::remove_panelcheck, before removing, whether the panel being closed contains the focused view. If it did, the panel the group now shows in its place (viaactive_panel) is focused. Closing a tab that never had focus changes nothing.Two tests cover both sides:
dock_hands_the_focus_to_the_tab_that_replaces_a_closed_one— closing the focused tab moves focus to the newly visible tab.dock_leaves_the_focus_alone_when_a_tab_without_it_closes— closing a background tab leaves focus where it was.No public API changes; behavior-only fix.
This PR is 100% AI-generated: originally drafted with Claude on 2026-10-04, rebased onto current main, reviewed and validated by the contributor:
cargo fmt --check,cargo clippy -p gpui-base --all-targets -- --deny warnings, and the dock test suite (4 passed, including the two new focus tests) are all green.