From ce9d21ad71aba4496e23efecac4d2b748a54d280 Mon Sep 17 00:00:00 2001 From: MH Johnson Date: Tue, 23 Jan 2024 16:44:53 -0500 Subject: [PATCH] Add click handler to links that prevents default --- lib/web_ui/lib/src/engine/semantics/link.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/web_ui/lib/src/engine/semantics/link.dart b/lib/web_ui/lib/src/engine/semantics/link.dart index 168c93322c430..819fe62cda4ac 100644 --- a/lib/web_ui/lib/src/engine/semantics/link.dart +++ b/lib/web_ui/lib/src/engine/semantics/link.dart @@ -16,6 +16,12 @@ class Link extends PrimaryRoleManager { // https://github.com/flutter/flutter/issues/102535. element.setAttribute('href', '#'); element.style.display = 'block'; + // Prevent the default action of clicking the anchor tag, which is to + // navigate to the href. Instead the click action is handled by the + // framework. + element.addEventListener('click', createDomEventListener((DomEvent event) { + event.preventDefault(); + })); return element; }