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

[Web][A11y] Fix link onClick behavior on links #49984

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/web_ui/lib/src/engine/semantics/link.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down