sidebar: Fix focus movement while toggling it on and off#53283
Merged
danilo-leal merged 3 commits intomainfrom Apr 7, 2026
Merged
sidebar: Fix focus movement while toggling it on and off#53283danilo-leal merged 3 commits intomainfrom
danilo-leal merged 3 commits intomainfrom
Conversation
cameron1024
approved these changes
Apr 7, 2026
MasoudAlali
pushed a commit
to MasoudAlali/zed-ide
that referenced
this pull request
Apr 7, 2026
…ies#53283) I was testing out the changes in zed-industries#52730 and realized that the agent panel, when full screen, would be auto-dismissed if I toggled the sidebar off. Turns out this happens because we were "hard-coding" the focus back to the center pane, which was automatically dismissing zoomed items. So, in this PR, I essentially am copying the ModalLayer approach of storing whatever was focused before so we can return focus back to it if possible. Release Notes: - N/A
danilo-leal
added a commit
that referenced
this pull request
Apr 8, 2026
Follow up to #53283. That PR replaced _where_ focus goes — from "always the center pane" to "the saved element." But it didn't fix _when_ focus moves — it still moves every time the sidebar closes, unconditionally. The problem is the saved focus can be wrong... it's saved when the sidebar opens, but then it can go to somewhere else after. An example: 1. Open sidebar → save focus (center pane), focus sidebar 2. Open agent panel from sidebar → focus moves to agent panel 3. Close sidebar → restore saved focus → **focuses center pane** (that's what was saved in step 1, not the agent panel) Effectively, this would still cause the agent panel to auto-dismiss. This PR fixes it by no moving focus at all if the sidebar doesn't have it. If the user already moved focus to the agent panel, there's nothing to "restore". Release Notes: - N/A
Caio-Ze
pushed a commit
to Caio-Ze/postprod-ide
that referenced
this pull request
Apr 8, 2026
…es#53386) Follow up to zed-industries#53283. That PR replaced _where_ focus goes — from "always the center pane" to "the saved element." But it didn't fix _when_ focus moves — it still moves every time the sidebar closes, unconditionally. The problem is the saved focus can be wrong... it's saved when the sidebar opens, but then it can go to somewhere else after. An example: 1. Open sidebar → save focus (center pane), focus sidebar 2. Open agent panel from sidebar → focus moves to agent panel 3. Close sidebar → restore saved focus → **focuses center pane** (that's what was saved in step 1, not the agent panel) Effectively, this would still cause the agent panel to auto-dismiss. This PR fixes it by no moving focus at all if the sidebar doesn't have it. If the user already moved focus to the agent panel, there's nothing to "restore". Release Notes: - N/A
rtfeldman
pushed a commit
that referenced
this pull request
Apr 10, 2026
Follow up to #53283. That PR replaced _where_ focus goes — from "always the center pane" to "the saved element." But it didn't fix _when_ focus moves — it still moves every time the sidebar closes, unconditionally. The problem is the saved focus can be wrong... it's saved when the sidebar opens, but then it can go to somewhere else after. An example: 1. Open sidebar → save focus (center pane), focus sidebar 2. Open agent panel from sidebar → focus moves to agent panel 3. Close sidebar → restore saved focus → **focuses center pane** (that's what was saved in step 1, not the agent panel) Effectively, this would still cause the agent panel to auto-dismiss. This PR fixes it by no moving focus at all if the sidebar doesn't have it. If the user already moved focus to the agent panel, there's nothing to "restore". Release Notes: - N/A
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.
I was testing out the changes in #52730 and realized that the agent panel, when full screen, would be auto-dismissed if I toggled the sidebar off. Turns out this happens because we were "hard-coding" the focus back to the center pane, which was automatically dismissing zoomed items. So, in this PR, I essentially am copying the ModalLayer approach of storing whatever was focused before so we can return focus back to it if possible.
Release Notes: