Skip to content

gpui: Fix hover state getting stuck when rapidly hovering over elements#45437

Merged
MrSubidubi merged 3 commits intozed-industries:mainfrom
errmayank:gpui-hover-state
Dec 21, 2025
Merged

gpui: Fix hover state getting stuck when rapidly hovering over elements#45437
MrSubidubi merged 3 commits intozed-industries:mainfrom
errmayank:gpui-hover-state

Conversation

@errmayank
Copy link
Contributor

@errmayank errmayank commented Dec 20, 2025

Closes #45436

Release Notes:

  • N/A

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Dec 20, 2025
@github-actions github-actions bot added the community champion Issues filed by our amazing community champions! 🫶 label Dec 20, 2025
@errmayank
Copy link
Contributor Author

screen-recording-gpui-hover-state.mov
Here is the example I used
use gpui::{
    AppContext, Application, Bounds, Context, InteractiveElement, IntoElement, ParentElement,
    Render, Styled, Window, WindowBounds, WindowOptions, div, px, rgb, size,
};

struct App {}

impl Render for App {
    fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
        let background = rgb(0x1a1a1a);
        let item_bg_hover = rgb(0x292929);
        let text_default = rgb(0xd6d6dc);
        let text_hover = rgb(0xf0ab75);
        let border = rgb(0x4d4d4d);

        div()
            .flex()
            .flex_col()
            .size_full()
            .text_color(text_default)
            .bg(rgb(0x111111))
            .text_xs()
            .p_3()
            .child(div().mb_2().text_lg().text_center().child("Lists"))
            .child(
                div()
                    .flex()
                    .bg(background)
                    .border_1()
                    .border_color(border)
                    .rounded_md()
                    .py_2()
                    .children((0..10).map(|col| {
                        div().flex_1().children((1..=30).map(|idx| {
                            div()
                                .id(format!("item-{}-{}", col, idx))
                                .w_full()
                                .rounded_sm()
                                .flex()
                                .items_center()
                                .justify_center()
                                .hover(|style| {
                                    style.bg(item_bg_hover).text_color(text_hover).underline()
                                })
                                .child(format!("Item {}.{:02}", col + 1, idx))
                        }))
                    })),
            )
    }
}

fn main() {
    Application::new().run(|cx| {
        let bounds = Bounds::centered(None, size(px(900.), px(700.)), cx);
        cx.open_window(
            WindowOptions {
                window_bounds: Some(WindowBounds::Windowed(bounds)),
                ..Default::default()
            },
            |_window, cx| cx.new(|_cx| App {}),
        )
        .unwrap();
    });
}

@0PandaDEV
Copy link

I can confirm that the issue is fixed.

@MrSubidubi
Copy link
Member

Should be good to go after #45461

Copy link
Member

@MrSubidubi MrSubidubi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you!

I did remove the release notes though as this did not reach any release channel. Still really appreciate the quick follow-up! And talk to you in the other PR 🙂

@MrSubidubi MrSubidubi enabled auto-merge (squash) December 21, 2025 22:07
@MrSubidubi MrSubidubi merged commit 045e154 into zed-industries:main Dec 21, 2025
24 checks passed
@github-project-automation github-project-automation bot moved this from Community PRs to Done in Quality Week – December 2025 Dec 21, 2025
rtfeldman pushed a commit that referenced this pull request Jan 5, 2026
…ts (#45437)

Closes #45436

Release Notes:

- N/A

---------

Co-authored-by: MrSubidubi <finn@zed.dev>
danilo-leal added a commit that referenced this pull request Jan 8, 2026
Tackling this as I noticed a bug in the agent panel where the button to
delete a thread, which appeared only on hover, stopped showing up. PRs
#43324 and #45437 fixed stuff in applying hover styles through
`.hover()` but broke the `.on_hover()` callback. Problem was that both
methods were sharing the same `element_state.hover_state` but running at
different phases. The solution here was to add a new independent state
field for the hover listener (`hover_listener_state`) while the hover
style method keeps using `hover_state`.

Release Notes:

- Agent: Fixed a bug where the button to delete a thread stopped showing
up.
github-actions bot pushed a commit that referenced this pull request Jan 14, 2026
Tackling this as I noticed a bug in the agent panel where the button to
delete a thread, which appeared only on hover, stopped showing up. PRs
#43324 and #45437 fixed stuff in applying hover styles through
`.hover()` but broke the `.on_hover()` callback. Problem was that both
methods were sharing the same `element_state.hover_state` but running at
different phases. The solution here was to add a new independent state
field for the hover listener (`hover_listener_state`) while the hover
style method keeps using `hover_state`.

Release Notes:

- Agent: Fixed a bug where the button to delete a thread stopped showing
up.
zed-zippy bot added a commit that referenced this pull request Jan 14, 2026
#46831)

Cherry-pick of #46371 to stable

----
Tackling this as I noticed a bug in the agent panel where the button to
delete a thread, which appeared only on hover, stopped showing up. PRs
#43324 and #45437 fixed stuff in applying hover styles through
`.hover()` but broke the `.on_hover()` callback. Problem was that both
methods were sharing the same `element_state.hover_state` but running at
different phases. The solution here was to add a new independent state
field for the hover listener (`hover_listener_state`) while the hover
style method keeps using `hover_state`.

Release Notes:

- Agent: Fixed a bug where the button to delete a thread stopped showing
up.

Co-authored-by: Danilo Leal <67129314+danilo-leal@users.noreply.github.com>
LivioGama pushed a commit to LivioGama/zed that referenced this pull request Jan 20, 2026
…ts (zed-industries#45437)

Closes zed-industries#45436

Release Notes:

- N/A

---------

Co-authored-by: MrSubidubi <finn@zed.dev>
LivioGama pushed a commit to LivioGama/zed that referenced this pull request Jan 20, 2026
…ts (zed-industries#45437)

Closes zed-industries#45436

Release Notes:

- N/A

---------

Co-authored-by: MrSubidubi <finn@zed.dev>
LivioGama pushed a commit to LivioGama/zed that referenced this pull request Feb 15, 2026
…ts (zed-industries#45437)

Closes zed-industries#45436

Release Notes:

- N/A

---------

Co-authored-by: MrSubidubi <finn@zed.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement community champion Issues filed by our amazing community champions! 🫶

Projects

Development

Successfully merging this pull request may close these issues.

GPUI hover state stuck on rapidly hovering over elements

3 participants