# terminal: Don't steal focus from an open modal on background terminal startup \(\#60960\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 3f57e8d17d8b1cb83e96df6a627ba8f3c8407ac7

Requested commit: 3f57e8d17d8b1cb83e96df6a627ba8f3c8407ac7

Commit: 3f57e8d17d8b1cb83e96df6a627ba8f3c8407ac7

Tree: 622b477f4dd53233ace69d9cb804b214626e0116

Author: Apoorva Verma

Committer: GitHub

## Message

```
terminal: Don't steal focus from an open modal on background terminal startup (#60960)

the startup terminal can take a sec to come up if your shell is slow.
when it's ready it grabs focus, and if you've opened the command palette
by then, that blurs the palette input and closes it. so it just
vanishes.

`add_center_terminal` focused the new terminal unconditionally. now it
skips the focus if a modal is open (`!has_active_modal`). one line at
the definition, covers all the call sites.

kept it terminal-specific like dinocosta framed it. could do a broader
workspace-level "don't steal from a modal" instead if you'd prefer.

two tests: modal stays focused after a background terminal spawns (fails
without the fix), and no-modal still focuses the terminal like before.

Fixes #60762.

Release Notes:

- Fixed a background terminal finishing startup closing the command
palette or an open picker
```

## Parents

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

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