Repository navigation
[web:a11y] Link widget breaks when ensureSemantics is enabled #143164
Copy link
Copy link
Closed
flutter/packages
#6711Closed
Copy link
Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)Accessibility, e.g. VoiceOver or TalkBack. (aka a11y)customer: castawayplatform-webWeb applications specificallyWeb applications specificallyteam-webOwned by Web platform teamOwned by Web platform teamtriaged-webTriaged by Web platform teamTriaged by Web platform team
Description
Enabling semantics using SemanticsBinding.instance.ensureSemantics() causes the Link widget to break.
Steps to reproduce
- Create a new Flutter project and copy the contents below
- Run the app in Chrome and observe that the link doesn't work
- Comment out
SemanticsBinding.instance.ensureSemantics(), re-run and observe that the link now works.
Code snippet
main.dart:
import 'package:flutter/material.dart';
import 'package:flutter/semantics.dart';
import 'package:go_router/go_router.dart';
import 'package:url_launcher/link.dart';
import 'package:flutter_web_plugins/url_strategy.dart';
void main() {
usePathUrlStrategy();
runApp(const MyApp());
SemanticsBinding.instance.ensureSemantics();
}
final GoRouter _router = GoRouter(
routes: <RouteBase>[
GoRoute(
path: '/',
builder: (BuildContext context, GoRouterState state) {
return const HomeScreen();
},
routes: <RouteBase>[
GoRoute(
path: 'details-screen',
builder: (BuildContext context, GoRouterState state) {
return const DetailsScreen();
},
),
],
),
],
);
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp.router(
routerConfig: _router,
);
}
}
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Home Screen')),
body: Center(
child: Link(
builder: (context, followLink) {
return ElevatedButton(
onPressed: followLink,
child: const Text('Go to the Details screen'),
);
},
uri: Uri.parse('/details-screen'),
),
),
);
}
}
class DetailsScreen extends StatelessWidget {
const DetailsScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Details Screen')),
body: Center(
child: ElevatedButton(
onPressed: () => context.go('/'),
child: const Text('Go back to the Home screen'),
),
),
);
}
}pubspec.yaml
name: link_widget_bug
description: "A new Flutter project."
publish_to: 'none'
version: 0.1.0
environment:
sdk: '>=3.4.0-82.0.dev <4.0.0'
dependencies:
flutter:
sdk: flutter
flutter_web_plugins:
sdk: flutter
go_router: any
url_launcher: any
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^3.0.0
flutter:
uses-material-design: true
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 lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)Accessibility, e.g. VoiceOver or TalkBack. (aka a11y)customer: castawayplatform-webWeb applications specificallyWeb applications specificallyteam-webOwned by Web platform teamOwned by Web platform teamtriaged-webTriaged by Web platform teamTriaged by Web platform team
Activity
johnpryan commentedon Feb 8, 2024
cc: @mdebbar @yjbanov
emma-roudabush-disney commentedon Mar 4, 2024
I am also seeing this issue--we lose all link preview and context menu options
ss1565 commentedon Mar 14, 2024
I am also seeing this issue. When is this going to be fixed?
pedromassango commentedon Aug 19, 2024
This is still happing
[-]Link widget breaks when ensureSemantics is enabled[/-][+][web:a11y] Link widget breaks when ensureSemantics is enabled[/+][url_launcher][web] Better support for semantics in the Link widget (f…
github-actions commentedon Jan 24, 2025
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] Better support for semantics in the Link widget (f…
[url_launcher][web] Better support for semantics in the Link widget (f…
[url_launcher][web] Better support for semantics in the Link widget (f…
[url_launcher][web] Better support for semantics in the Link widget (f…