text_view: Stop propagation on click link in TextView. (#650)

To avoid trigger parent element, for example as a Label for checkbox.
This commit is contained in:
Jason Lee 2025-02-24 18:07:53 +08:00 committed by GitHub
parent 6bcc34c7f0
commit 3b4065ce4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);
}
}