Skip to content

Commit a9f7270

Browse files
authored
[web] Scope the mobile semantics placeholder to its view (flutter#190856)
Fixes flutter#152838 **Problem** Flutter Web puts an invisible "Enable accessibility" button on the page for screen reader users. On mobile it covered the whole page instead of just the Flutter app, swallowing taps meant for the surrounding HTML until about 20 taps made the engine remove it. Desktop was never affected: its button is one pixel and sits offscreen. **Fix** The button now lives inside `<flutter-view>` rather than `<body>`, one per view, so it can only cover the Flutter app. The CSS is unchanged, only the parent element, and it goes in as the first child so platform views keep their own events. **Demo** Before: https://flutter-demo-59-before.web.app After: https://flutter-demo-59-after.web.app Open either on a phone and tap the HTML links before touching the Flutter app. - Before: nothing responds. The links do not highlight and the log stays at "no HTML link clicked yet". They come alive only after tapping the Flutter app about 20 times. - After: the links respond on the first tap. Desktop browsers cannot show the difference, since they use the 1x1 placeholder on both builds.
1 parent c251c17 commit a9f7270

8 files changed

Lines changed: 564 additions & 107 deletions

File tree

‎engine/src/flutter/lib/web_ui/lib/src/engine/platform_dispatcher.dart‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
3737
registerHotRestartListener(dispose);
3838
_appLifecycleState.addListener(_setAppLifecycleState);
3939
_viewFocusBinding.init();
40-
domDocument.body?.prepend(accessibilityPlaceholder);
4140
_onViewDisposedListener = viewManager.onViewDisposed.listen((_) {
4241
// Send a metrics changed event to the framework when a view is disposed.
4342
// View creation/resize is handled by the `_didResize` handler in the
@@ -89,10 +88,6 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
8988
static EnginePlatformDispatcher get instance => _instance;
9089
static final EnginePlatformDispatcher _instance = EnginePlatformDispatcher();
9190

92-
@visibleForTesting
93-
DomElement get accessibilityPlaceholder =>
94-
EngineSemantics.instance.semanticsHelper.accessibilityPlaceholder;
95-
9691
PlatformConfiguration configuration = PlatformConfiguration(
9792
locales: parseBrowserLanguages(),
9893
textScaleFactor: findBrowserTextScaleFactor(),
@@ -114,7 +109,6 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
114109
_removeLocaleChangedListener();
115110
_appLifecycleState.removeListener(_setAppLifecycleState);
116111
_viewFocusBinding.dispose();
117-
accessibilityPlaceholder.remove();
118112
_onViewDisposedListener.cancel();
119113
viewManager.dispose();
120114
}

0 commit comments

Comments
 (0)