Skip to content

Commit 4819cab

Browse files
[url_launcher] fix: tab traversal on web (#10020)
1 parent 6b3706f commit 4819cab

File tree

5 files changed

+63
-25
lines changed

5 files changed

+63
-25
lines changed

packages/url_launcher/url_launcher_web/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 2.4.2
22

3+
* Fixes an issue that caused duplicate semantic nodes for `Link` widgets.
34
* Updates minimum supported SDK version to Flutter 3.32/Dart 3.8.
45

56
## 2.4.1

packages/url_launcher/url_launcher_web/example/integration_test/link_widget_test.dart

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,43 @@ void main() {
206206
maxScrolls: 1000,
207207
);
208208
});
209+
210+
testWidgets('MergeSemantics is always present to avoid duplicate nodes', (
211+
WidgetTester tester,
212+
) async {
213+
await tester.pumpWidget(
214+
MaterialApp(
215+
home: Scaffold(
216+
body: Column(
217+
children: <Widget>[
218+
WebLinkDelegate(
219+
TestLinkInfo(
220+
uri: Uri.parse('https://dart.dev/xyz'),
221+
target: LinkTarget.blank,
222+
builder: (BuildContext context, FollowLink? followLink) {
223+
return ElevatedButton(
224+
onPressed: followLink,
225+
child: const Text('First Button'),
226+
);
227+
},
228+
),
229+
),
230+
],
231+
),
232+
),
233+
),
234+
);
235+
236+
await tester.pumpAndSettle();
237+
238+
final Finder buttonFinder = find.byType(ElevatedButton);
239+
expect(buttonFinder, findsOneWidget);
240+
241+
final Element buttonElement = tester.element(buttonFinder);
242+
final MergeSemantics? parentWidget = buttonElement
243+
.findAncestorWidgetOfExactType<MergeSemantics>();
244+
expect(parentWidget, isNotNull);
245+
});
209246
});
210247

211248
group('Follows links', () {
@@ -895,17 +932,13 @@ void main() {
895932
isLink: true,
896933
identifier: 'test-link-12',
897934
// linkUrl: 'https://foobar/example?q=1',
898-
children: <Matcher>[
899-
matchesSemantics(
900-
hasTapAction: true,
901-
hasEnabledState: true,
902-
hasFocusAction: true,
903-
isEnabled: true,
904-
isButton: true,
905-
isFocusable: true,
906-
label: 'Button Link Text',
907-
),
908-
],
935+
hasTapAction: true,
936+
hasEnabledState: true,
937+
hasFocusAction: true,
938+
isEnabled: true,
939+
isButton: true,
940+
isFocusable: true,
941+
label: 'Button Link Text',
909942
),
910943
);
911944

@@ -941,7 +974,9 @@ void main() {
941974
final Finder linkFinder = find.byKey(linkKey);
942975
expect(
943976
tester.getSemantics(
944-
find.descendant(of: linkFinder, matching: find.byType(Semantics)),
977+
find
978+
.descendant(of: linkFinder, matching: find.byType(Semantics))
979+
.first,
945980
),
946981
matchesSemantics(
947982
isLink: true,

packages/url_launcher/url_launcher_web/example/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ name: regular_integration_tests
22
publish_to: none
33

44
environment:
5-
sdk: ^3.8.0
6-
flutter: ">=3.32.0"
5+
sdk: ^3.10.0
6+
flutter: ">=3.38.0"
77

88
dependencies:
99
flutter:

packages/url_launcher/url_launcher_web/lib/src/link.dart

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,15 @@ class WebLinkDelegateState extends State<WebLinkDelegate> {
117117
}
118118

119119
Widget _buildChild(BuildContext context) {
120-
return Semantics(
121-
link: true,
122-
identifier: _semanticsIdentifier,
123-
linkUrl: widget.link.uri,
124-
child: widget.link.builder(
125-
context,
126-
widget.link.isDisabled ? null : _followLink,
120+
return MergeSemantics(
121+
child: Semantics(
122+
link: true,
123+
identifier: _semanticsIdentifier,
124+
linkUrl: widget.link.uri,
125+
child: widget.link.builder(
126+
context,
127+
widget.link.isDisabled ? null : _followLink,
128+
),
127129
),
128130
);
129131
}

packages/url_launcher/url_launcher_web/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ name: url_launcher_web
22
description: Web platform implementation of url_launcher
33
repository: https://github.com/flutter/packages/tree/main/packages/url_launcher/url_launcher_web
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+url_launcher%22
5-
version: 2.4.1
5+
version: 2.4.2
66

77
environment:
8-
sdk: ^3.8.0
9-
flutter: ">=3.32.0"
8+
sdk: ^3.10.0
9+
flutter: ">=3.38.0"
1010

1111
flutter:
1212
plugin:

0 commit comments

Comments
 (0)