Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d3e16ea
[url_launcher][web] Better support for semantics in the Link widget
mdebbar May 9, 2024
cce04c4
tests
mdebbar May 20, 2024
b3d16c7
click on mismatched link
mdebbar May 22, 2024
f684065
more tests
mdebbar May 22, 2024
c1556cc
semantics tests
mdebbar May 31, 2024
d98eab2
apply the target attribute on semantic links
mdebbar May 31, 2024
66df2e2
always use plural 'semantics'
mdebbar Jun 3, 2024
c359fd4
changes to semanticsIdentifier
mdebbar Jun 3, 2024
7fd5b7b
more attributes on <a>
mdebbar Jun 4, 2024
80e7158
more readable
mdebbar Jun 4, 2024
9d02101
correct attribute name 'flt-semantics-identifier'
mdebbar Aug 13, 2024
3b33642
Merge branch 'main' into new_link_semantics
mdebbar Aug 13, 2024
5334922
use the new linkUrl semantics property
mdebbar Aug 13, 2024
9955360
triggerIfReady
mdebbar Aug 13, 2024
af67dfc
docs
mdebbar Aug 13, 2024
393776a
Merge branch 'main' into link_semantics
mdebbar Nov 22, 2024
969e697
Merge branch 'main' into link_semantics
mdebbar Dec 17, 2024
2c37827
Merge branch 'main' into link_semantics
mdebbar Dec 19, 2024
aa0c3d7
bump minimum sdk version
mdebbar Dec 23, 2024
ba6c60f
Merge branch 'main' into link_semantics
mdebbar Dec 27, 2024
f296c49
dart format
mdebbar Dec 27, 2024
46ca0e7
Merge branch 'main' into link_semantics
ditman Jan 8, 2025
114731d
Help test pass in wasm
ditman Jan 8, 2025
4cd3f68
dart format .
ditman Jan 8, 2025
c203542
Tag as v2.4.0, update CHANGELOG.
ditman Jan 9, 2025
c12a920
Update sdk lower bound in example.
ditman Jan 9, 2025
4e703d5
Address PR comments.
ditman Jan 10, 2025
286d33d
Rename signal handlers to onSignalName
ditman Jan 10, 2025
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
Prev Previous commit
Next Next commit
dart format
  • Loading branch information
mdebbar committed Dec 27, 2024
commit f296c493d62940cdc1eecf9472d04b34da1c13a2
Original file line number Diff line number Diff line change
Expand Up @@ -933,18 +933,21 @@ void main() {
// Platform view creation happens asynchronously.
await tester.pumpAndSettle();

final html.Element semanticsHost = html.document.createElement('flt-semantics-host');
final html.Element semanticsHost =
html.document.createElement('flt-semantics-host');
html.document.body!.append(semanticsHost);
final html.Element semanticsAnchor = html.document.createElement('a')
..setAttribute('id', 'flt-semantic-node-99')
..setAttribute('flt-semantics-identifier', 'test-link-27')
..setAttribute('href', '/foobar');
semanticsHost.append(semanticsAnchor);
final html.Element semanticsContainer = html.document.createElement('flt-semantics-container');
final html.Element semanticsContainer =
html.document.createElement('flt-semantics-container');
semanticsAnchor.append(semanticsContainer);
final html.Element semanticsButton = html.document.createElement('flt-semantics')
..setAttribute('role', 'button')
..textContent = 'My Button Link';
final html.Element semanticsButton =
html.document.createElement('flt-semantics')
..setAttribute('role', 'button')
..textContent = 'My Button Link';
semanticsContainer.append(semanticsButton);

expect(pushedRouteNames, isEmpty);
Expand Down Expand Up @@ -999,7 +1002,8 @@ void main() {
// Platform view creation happens asynchronously.
await tester.pumpAndSettle();

final html.Element semanticsHost = html.document.createElement('flt-semantics-host');
final html.Element semanticsHost =
html.document.createElement('flt-semantics-host');
html.document.body!.append(semanticsHost);
final html.Element semanticsAnchor = html.document.createElement('a')
..setAttribute('id', 'flt-semantic-node-99')
Expand Down Expand Up @@ -1046,17 +1050,20 @@ void main() {
// Platform view creation happens asynchronously.
await tester.pumpAndSettle();

final html.Element semanticsHost = html.document.createElement('flt-semantics-host');
final html.Element semanticsHost =
html.document.createElement('flt-semantics-host');
html.document.body!.append(semanticsHost);
final html.Element semanticsAnchor = html.document.createElement('a')
..setAttribute('id', 'flt-semantic-node-99')
..setAttribute('href', '#');
semanticsHost.append(semanticsAnchor);
final html.Element semanticsContainer = html.document.createElement('flt-semantics-container');
final html.Element semanticsContainer =
html.document.createElement('flt-semantics-container');
semanticsAnchor.append(semanticsContainer);
final html.Element semanticsButton = html.document.createElement('flt-semantics')
..setAttribute('role', 'button')
..textContent = 'My Button';
final html.Element semanticsButton =
html.document.createElement('flt-semantics')
..setAttribute('role', 'button')
..textContent = 'My Button';
semanticsContainer.append(semanticsButton);

expect(pushedRouteNames, isEmpty);
Expand Down Expand Up @@ -1102,7 +1109,8 @@ void main() {
// Platform view creation happens asynchronously.
await tester.pumpAndSettle();

final html.Element semanticsHost = html.document.createElement('flt-semantics-host');
final html.Element semanticsHost =
html.document.createElement('flt-semantics-host');
html.document.body!.append(semanticsHost);
final html.Element semanticsAnchor = html.document.createElement('a')
..setAttribute('id', 'flt-semantic-node-99')
Expand Down
25 changes: 14 additions & 11 deletions packages/url_launcher/url_launcher_web/lib/src/link.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ class WebLinkDelegateState extends State<WebLinkDelegate> {
final JSAny _useCapture = <String, Object>{'capture': true}.jsify()!;

/// Signature for the function that triggers a link.
typedef TriggerLinkCallback = void Function(int viewId, html.MouseEvent? mouseEvent);
typedef TriggerLinkCallback = void Function(
int viewId, html.MouseEvent? mouseEvent);

/// Keeps track of the signals required to trigger a link.
///
Expand Down Expand Up @@ -316,7 +317,8 @@ class LinkViewController extends PlatformViewController {
String semanticsIdentifier,
) {
final int viewId = params.id;
final LinkViewController controller = LinkViewController(viewId, semanticsIdentifier);
final LinkViewController controller =
LinkViewController(viewId, semanticsIdentifier);
controller._initialize().then((_) {
/// Because _initialize is async, it can happen that [LinkViewController.dispose]
/// may get called before this `then` callback.
Expand All @@ -338,11 +340,10 @@ class LinkViewController extends PlatformViewController {
return _instancesByViewId[viewId]!._element;
}

static final LinkTriggerSignals _triggerSignals =
LinkTriggerSignals(
triggerLink: _triggerLink,
staleTimeout: const Duration(milliseconds: 500),
);
static final LinkTriggerSignals _triggerSignals = LinkTriggerSignals(
triggerLink: _triggerLink,
staleTimeout: const Duration(milliseconds: 500),
);

static final JSFunction _jsGlobalKeydownListener = _onGlobalKeydown.toJS;
static final JSFunction _jsGlobalClickListener = _onGlobalClick.toJS;
Expand Down Expand Up @@ -445,8 +446,8 @@ class LinkViewController extends PlatformViewController {
}) {
// We only want to handle clicks that land on *our* links. That could be a
// platform view link or a semantics link.
final int? viewIdFromTarget = _getViewIdFromLink(target) ??
_getViewIdFromSemanticsLink(target);
final int? viewIdFromTarget =
_getViewIdFromLink(target) ?? _getViewIdFromSemanticsLink(target);

if (viewIdFromTarget == null) {
// The click target was not one of our links, so we don't want to
Expand Down Expand Up @@ -596,12 +597,14 @@ class LinkViewController extends PlatformViewController {
return null;
}

final String? semanticsIdentifier = semanticsLink.getAttribute('flt-semantics-identifier');
final String? semanticsIdentifier =
semanticsLink.getAttribute('flt-semantics-identifier');
if (semanticsIdentifier == null) {
return null;
}

final LinkViewController? controller = _instancesBySemanticsIdentifier[semanticsIdentifier];
final LinkViewController? controller =
_instancesBySemanticsIdentifier[semanticsIdentifier];
if (controller == null) {
return null;
}
Expand Down
Loading