# workspace: Fix captured focus when opening modals \(\#63512\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 837264129f6feff948d93dcd62a6cc1b303b2cc4

Requested commit: 837264129f6feff948d93dcd62a6cc1b303b2cc4

Commit: 837264129f6feff948d93dcd62a6cc1b303b2cc4

Tree: dd9b847d59960c2ca6fd833ae6a42c87b9c80969

Author: Matei Oprea

Committer: GitHub

## Message

```
workspace: Fix captured focus when opening modals (#63512)

# Objective

- This PR fixes the captured focus in modals. 
- Fixes #63480 (and actually this was not specific to the task modal. it
was generic and applied to all modals)

## Solution

- Previously when a modal was opened the `previous_focus_handle` was
stealing the focus because it was captured in `show_modal`. The fix was
to capture it before calling `show_modal` or `reveal_stashed_modal` and
pass it to `show_modal`. That fixes the bug :) (yuhuu).

## Testing

- Tested by running the build and trying to reproduce the bug. I
couldn't reproduce it anymore.
- For testing, a reviewer also needs to test the revelal stashed modal
functionality. I did it with the file finder.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Fixed previous window focus handle not being captured correctly when
opening modals
```

## Parents

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

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