# sidebar: Fix focus movement while toggling it on and off \(\#53283\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/a856093ccafa7b422080f3073097560b04e8918d)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: a856093ccafa7b422080f3073097560b04e8918d

Requested commit: a856093ccafa7b422080f3073097560b04e8918d

Commit: a856093ccafa7b422080f3073097560b04e8918d

Tree: 975d88c8c66d8d5e19f48fa494ba2830d7c99b62

Author: Danilo Leal

Committer: GitHub

## Message

```
sidebar: Fix focus movement while toggling it on and off (#53283)

I was testing out the changes in
https://github.com/zed-industries/zed/pull/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
```

## Parents

- [3ed1c32bf9a1ebb485e3da6cabc8b3c0a423beea](https://git.cafe/gitcafe/zed/commit/3ed1c32bf9a1ebb485e3da6cabc8b3c0a423beea?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/a856093ccafa7b422080f3073097560b04e8918d?format=markdown)
