From 76bf4686ef35be8ce067d198cfa639e871f99d13 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Thu, 23 Jan 2025 14:58:07 -0500 Subject: [PATCH] ui: Don't add an `on_click` handler for disabled `ListItem`s (#23569) This PR updates the `ListItem` component to not register an `on_click` handler for `ListItem`s that are disabled. When working on #23350 I noticed that even when the context menu entry was disabled you could still click on the entry to fire the action. Release Notes: - Fixed some instances of disabled list items still registering clicks. --- crates/ui/src/components/list/list_item.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/ui/src/components/list/list_item.rs b/crates/ui/src/components/list/list_item.rs index e9fb9f9243289a581a33d4c79e344b443a06c359..a7efaecf9190407711aefe354e90ef9111a4d43c 100644 --- a/crates/ui/src/components/list/list_item.rs +++ b/crates/ui/src/components/list/list_item.rs @@ -245,9 +245,10 @@ impl RenderOnce for ListItem { }) }) }) - .when_some(self.on_click, |this, on_click| { - this.cursor_pointer().on_click(on_click) - }) + .when_some( + self.on_click.filter(|_| !self.disabled), + |this, on_click| this.cursor_pointer().on_click(on_click), + ) .when(self.outlined, |this| { this.border_1() .border_color(cx.theme().colors().border)