Skip to content

Commit

Permalink
[web] Don't add href="#" to semantics links (#53395)
Browse files Browse the repository at this point in the history
This is a stopgap for issues like flutter/flutter#146291 until we land better link semantics (in flutter/flutter#150263 and flutter/packages#6711). For the time being, the `href="#"` isn't providing any extra value, and is causing the browser to navigate to to `#` whenever the semantics link is clicked, which is undesirable.

Fixes flutter/flutter#146291
  • Loading branch information
mdebbar authored Jun 20, 2024
1 parent 043d7ab commit 1ad7953
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/web_ui/lib/src/engine/semantics/link.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ class Link extends PrimaryRoleManager {
@override
DomElement createElement() {
final DomElement element = domDocument.createElement('a');
// TODO(chunhtai): Fill in the real link once the framework sends entire uri.
// https://github.com/flutter/flutter/issues/102535.
element.setAttribute('href', '#');
// TODO(mdebbar): Fill in the real link once the framework sends entire uri.
// https://github.com/flutter/flutter/issues/150263.
element.style.display = 'block';
return element;
}
Expand Down
1 change: 1 addition & 0 deletions lib/web_ui/test/engine/semantics/semantics_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3536,6 +3536,7 @@ void _testLink() {

final SemanticsObject object = pumpSemantics();
expect(object.element.tagName.toLowerCase(), 'a');
expect(object.element.hasAttribute('href'), isFalse);
});
}

Expand Down

0 comments on commit 1ad7953

Please sign in to comment.