# project_panel: Make the window deactivation test actually deactivate \(\#62724\) · gitcafe/zed

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

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

Visibility: public

Requested revision: eedd20160f985a3784a8ca059781d86af20c8e7a

Requested commit: eedd20160f985a3784a8ca059781d86af20c8e7a

Commit: eedd20160f985a3784a8ca059781d86af20c8e7a

Tree: 8ef03affe20d5dcb5a95a2b9abe041534c842d8d

Author: Mikhail Butvin

Committer: GitHub

## Message

```
project_panel: Make the window deactivation test actually deactivate (#62724)

Follow-up to #61852. The regression test I added there passes with or
without the fix.

The test creates the panel with `ProjectPanel::new` but never calls
`workspace.add_panel(...)`, so the panel is never rendered and its
filename editor never holds window focus. Deactivating the window then
blurs nothing, the project panel's `Blurred` handler never runs, and the
assertion holds trivially.

Add the panel to the workspace so it renders and its filename editor
takes focus, and assert that the editor is focused before deactivating,
so the test fails at an explanatory precondition rather than silently
going vacuous again.

Verified by running the new precondition without `add_panel`: it fails,
because the workspace's `on_focus_lost` fallback
(`crates/workspace/src/workspace.rs:1667`) reclaims focus from an editor
that was never rendered into the dispatch tree.

## Suggested .rules additions

> A GPUI test that depends on focus must put the view somewhere it can
actually be focused. Constructing a panel with `ProjectPanel::new` and
friends does not render it, so its editors never hold window focus and
every focus or blur assertion passes vacuously. Add it with
`workspace.add_panel(...)`, and assert the intended editor `is_focused`
before exercising blur.

Release Notes:

- N/A
```

## Parents

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

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