# Fix lost focus when navigating back in project search result \(\#22483\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 6b16a5555e713a53c2820e5397c94f26732e6cd7

Requested commit: 6b16a5555e713a53c2820e5397c94f26732e6cd7

Commit: 6b16a5555e713a53c2820e5397c94f26732e6cd7

Tree: 5b8d5d507431b448173186e16dd4775c1900c27a

Author: feeiyu

Committer: GitHub

## Message

```
Fix lost focus when navigating back in project search result (#22483)

Closes #22447

When navigate forward/back, the focus moves from the ProjectSearchView's
result editor to the Pane, and then move to the ProjectSearchView, but
the event `on_focus_in` not triggered for ProjectSearchView, causing the
result editor to lose focus eventually.


https://github.com/zed-industries/zed/blob/f6dabadaf79bd29c89c8d55a1e9f1d33236f736e/crates/workspace/src/workspace.rs#L1372


https://github.com/zed-industries/zed/blob/f6dabadaf79bd29c89c8d55a1e9f1d33236f736e/crates/workspace/src/workspace.rs#L1385

Considering that the navigation might be triggered again in the next
frame, so use `on_next_frame` in `on_focus` event to move focus to
result editor.

Next frame:
- the blur event triggered for result editor.
- focus move from ProjectSearchView to result editor in `on_focus` event
for ProjectSearchView
- navigate again, focus moves from result editor to Pane then move back
to ProjectSearchView
- the focus not change during this frame, so no focus event happened for
ProjectSearchView.

![fix lost
focus1229](https://github.com/user-attachments/assets/bfaac839-7bcf-40e7-b3b4-1423d0510594)

Release Notes:

- Fix lost focus when navigate back in project search result

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
```

## Parents

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

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