Skip to content

Commit

Permalink
Add click handler to links that prevents default
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsonmh authored Jan 23, 2024
1 parent 2f53605 commit ce9d21a
Showing 1 changed file with 6 additions and 0 deletions.
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

0 comments on commit ce9d21a

Please sign in to comment.