Repository navigation
Link widget not working from keyboard on web #97863
Copy link
Copy link
Closed
flutter/packages
#6505Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work listfound in release: 3.10Found to occur in 3.10Found to occur in 3.10found in release: 3.11Found to occur in 3.11Found to occur in 3.11has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: url_launcherPlugin to launch external applicationsPlugin to launch external applicationspackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-webWeb applications specificallyWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-webOwned by Web platform teamOwned by Web platform teamtriaged-webTriaged by Web platform teamTriaged by Web platform team
Description
Steps to Reproduce
flutter create bug_linkflutter pub add url_launcher(as of writing this, it adds version 6.0.18 of url_launcher)replace main.dart with sample code- flutter run -d chrome
- Use TAB key to navigate and then SPACE or ENTER to trigger the buttons
You notice that the first button that is not built using Link widget will open https://flutter.dev in a new tab. But the second button does nothing when you use the SPACE or ENTER key on your keyboard.
Expected results:
I expect that both buttons works the same when navigating the app on keyboard.
Actual results:
The button that uses Link widget does not work to "tap" using keyboard.
Sample code - main.dart
import 'package:flutter/material.dart';
import 'package:url_launcher/link.dart';
import 'package:url_launcher/url_launcher.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
static const url = 'https://flutter.dev';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Link'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ElevatedButton(
onPressed: () {
launch(url);
},
child: const Text('Button without Link'),
),
Container(height: 20),
Link(
uri: Uri.parse(url),
target: LinkTarget.blank,
builder: (context, followLink) => ElevatedButton(
child: const Text('Button with Link'),
onPressed: followLink!,
),
),
],
),
),
);
}
}Logs
flutter analyze
Analyzing bug_link...
No issues found! (ran in 3.8s)
flutter doctor -v
[✓] Flutter (Channel stable, 2.10.0, on Microsoft Windows [Version 10.0.19044.1466], locale sv-SE)
• Flutter version 2.10.0 at C:\Users\Leif\Programmering\Libraries\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 5f105a6ca7 (4 days ago), 2022-02-01 14:15:42 -0800
• Engine revision 776efd2034
• Dart version 2.16.0
• DevTools version 2.9.2
[✓] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[✓] VS Code, 32-bit edition (version 1.61.2)
• VS Code at C:\Program Files (x86)\Microsoft VS Code
• Flutter extension version 3.29.0
[✓] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19044.1466]
• Chrome (web) • chrome • web-javascript • Google Chrome 97.0.4692.99
• Edge (web) • edge • web-javascript • Microsoft Edge 97.0.1072.69
[✓] HTTP Host Availability
• All required HTTP hosts are available
bug_link.mp4
Framework code
I did lookup the implementation of the Link widget and see that the followLink() method only registers a binding that is then used when onClick event of the A tag is getting called. So there is probably missing event handlers for keyboard triggering of the link.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work listfound in release: 3.10Found to occur in 3.10Found to occur in 3.10found in release: 3.11Found to occur in 3.11Found to occur in 3.11has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: url_launcherPlugin to launch external applicationsPlugin to launch external applicationspackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-webWeb applications specificallyWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-webOwned by Web platform teamOwned by Web platform teamtriaged-webTriaged by Web platform teamTriaged by Web platform team

Activity
darshankawar commentedon Feb 7, 2022
@Leffe108
Verified this on latest stable and master and confirmed that this behavior occurs only on web, as on desktop (tried on macOS), the link open properly after tapping from keyboard as expected, but, on web (using both renderers), tab focussed on
Button with linkbutton and then hitreturnfrom keyboard, but doesn't perform any action.stable, master flutter doctor -v
ditman commentedon Jun 4, 2022
I can repro this in the latest Flutter from
master(we pushed a fix that improved accessibility of platform views, but it didn't do the trick for this one). I'll follow up with @mdebbar for next steps! Thanks for the report!12 remaining items
[url_launcher][web] Link should work when triggered by keyboard (#6505)
github-actions commentedon Apr 30, 2024
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.[url_launcher][web] Link should work when triggered by keyboard (flut…
[url_launcher][web] Link should work when triggered by keyboard (flut…
[url_launcher][web] Link should work when triggered by keyboard (flut…