Skip to content

The Popover closes before the list item click handler runs because blur fires first. #2081

@doubo6sir

Description

@doubo6sir

Description

When using a list inside a popover, the popover is closed on the list’s blur event. However, blur fires before the list item’s on_click, so clicking an item never triggers the click handler. Would using on_mouse_down instead of on_click be the correct approach?

Image

Environment

  • GPUI: main [83ca310]
  • GPUI Component: main [be65753]
  • Platform: [macOS 26]

Steps to Reproduce

  • code example
 Popover::new("popover-recent-projects")
            .max_w(px(600.))
            .trigger(
                Button::new("recent-proejcts-trigger")
                    .ghost()
                    .small()
                    .cursor_pointer()
                    .compact()
                    .tab_stop(false)
                    .label(SharedString::new(name)),
            )
            .p_0()
            .overlay_closable(self.popover_overlay)
            .open(self.popover_open)
            .on_open_change(cx.listener(move |this, open, window, cx| {
                this.toggle(*open, window, cx);
            }))
            .text_sm()
            .h(px(200.))
            .w(px(360.))
            .when_some(list, |this, list| this.child(List::new(&list)))
            .child(Divider::horizontal())
            .child(
                div().flex().p_2().items_center().justify_end().child(
                    Button::new("open")
                        .ghost()
                        .small()
                        .compact()
                        .cursor_pointer()
                        .tab_stop(false)
                        .gap_2()
                        .child(SharedString::new("Open Project Folder"))
                        .child(Kbd::new(Keystroke::parse("cmd-shift-o").unwrap()).appearance(false))
                        .on_click(cx.listener(|this, _, window, cx| {
                            this.open_project_folder(window, cx);
                        })),
                ),
            )
            .anchor(Corner::TopLeft)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions