From b1bae7ca21b8247356a93da6be45a3703967d913 Mon Sep 17 00:00:00 2001 From: Jens Krause <47693+sectore@users.noreply.github.com> Date: Sun, 9 Feb 2025 04:04:54 +0100 Subject: [PATCH] color_picker: Fix popup does not close by clicking color button again. (#608) --- crates/ui/src/color_picker.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/crates/ui/src/color_picker.rs b/crates/ui/src/color_picker.rs index 649ee1fa..e5214af0 100644 --- a/crates/ui/src/color_picker.rs +++ b/crates/ui/src/color_picker.rs @@ -160,7 +160,6 @@ impl ColorPicker { fn on_escape(&mut self, _: &Escape, _: &mut Window, cx: &mut Context) { cx.propagate(); - self.open = false; cx.notify(); } @@ -335,6 +334,10 @@ impl Render for ColorPicker { ) .when_some(self.label.clone(), |this, label| this.child(label)) .on_click(cx.listener(Self::toggle_picker)) + .on_mouse_up_out( + MouseButton::Left, + cx.listener(|view, _, window, cx| view.on_escape(&Escape, window, cx)), + ) .child( canvas( move |bounds, _, cx| view.update(cx, |r, _| r.bounds = bounds), @@ -367,12 +370,6 @@ impl Render for ColorPicker { .shadow_lg() .rounded(cx.theme().radius) .bg(cx.theme().background) - .on_mouse_up_out( - MouseButton::Left, - cx.listener(|view, _, window, cx| { - view.on_escape(&Escape, window, cx) - }), - ) .child(self.render_colors(window, cx)), ), )