From 3b4065ce4eca18ddb435fe6ae5bed818bf95c221 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Mon, 24 Feb 2025 18:07:53 +0800 Subject: [PATCH] text_view: Stop propagation on click link in TextView. (#650) To avoid trigger parent element, for example as a Label for checkbox. --- crates/ui/src/text/element.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/ui/src/text/element.rs b/crates/ui/src/text/element.rs index 6842f58d..3249405d 100644 --- a/crates/ui/src/text/element.rs +++ b/crates/ui/src/text/element.rs @@ -303,6 +303,10 @@ impl RenderOnce for Paragraph { let links = links.clone(); move |ix, _, cx| { if let Some((_, link)) = &links.get(ix) { + // Stop propagation to prevent the parent element from handling the event. + // + // For example the text in a checkbox label, click link need avoid toggle check state. + cx.stop_propagation(); cx.open_url(&link.url); } }