Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit ce9d21a

Browse files
authored
Add click handler to links that prevents default
1 parent 2f53605 commit ce9d21a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/web_ui/lib/src/engine/semantics/link.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ class Link extends PrimaryRoleManager {
1616
// https://github.com/flutter/flutter/issues/102535.
1717
element.setAttribute('href', '#');
1818
element.style.display = 'block';
19+
// Prevent the default action of clicking the anchor tag, which is to
20+
// navigate to the href. Instead the click action is handled by the
21+
// framework.
22+
element.addEventListener('click', createDomEventListener((DomEvent event) {
23+
event.preventDefault();
24+
}));
1925
return element;
2026
}
2127

0 commit comments

Comments
 (0)