# theme_selector: Revert theme when modal is dismissed by clicking outside \(\#52773\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 16466ea9366782614fea266dfd1aae38e2a5a9be

Requested commit: 16466ea9366782614fea266dfd1aae38e2a5a9be

Commit: 16466ea9366782614fea266dfd1aae38e2a5a9be

Tree: f00caacda42c1551690360039a33951f7dd336d2

Author: João Soares

Committer: GitHub

## Message

```
theme_selector: Revert theme when modal is dismissed by clicking outside (#52773)

Context

Related to #52118

Found this while looking into the theme selector filtering bug: clicking
outside the theme selector (or icon theme selector) keeps the previewed
theme applied instead of reverting. `hide_modal()` doesn't go through
the Picker's `dismissed()` callback, so the in-memory theme override
sticks around without being written to `settings.json`.

This PR only fixes the click-outside behavior. The filtering issue from
#52118 is separate.

## Demo

**Before (bug):**


https://github.com/user-attachments/assets/f8be49c4-7e1d-483c-bf23-346022ac83aa



**After (fix):**



https://github.com/user-attachments/assets/29cc1740-c869-42d1-8aee-fe46a091a949



## How to review

Two files, symmetrical changes. Look at:
- `on_before_dismiss` in `theme_selector.rs` and
`icon_theme_selector.rs`
- The extracted `revert_theme()` method on both delegates, now shared
between `dismissed()` and `on_before_dismiss`

## Self-Review Checklist

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


Release Notes:

- Fixed theme selector keeping the previewed theme when clicking outside
instead of reverting to the original.
```

## Parents

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

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