This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
lib/src/engine/platform_dispatcher
test/engine/platform_dispatcher Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 33// found in the LICENSE file.
44
55import 'dart:async' ;
6+ import 'package:meta/meta.dart' ;
67import 'package:ui/src/engine.dart' ;
78import 'package:ui/ui.dart' as ui;
89
910/// Tracks the [FlutterView] s focus changes.
1011final class ViewFocusBinding {
1112 ViewFocusBinding (this ._viewManager, this ._onViewFocusChange);
1213
14+
15+ /// Wether [FlutterView] focus changes will be reported and performed.
16+ ///
17+ /// DO NOT rely on this bit as it will go away soon. You're warned :)!
18+ @visibleForTesting
19+ static bool isEnabled = false ;
20+
1321 final FlutterViewManager _viewManager;
1422 final ui.ViewFocusChangeCallback _onViewFocusChange;
1523
@@ -35,6 +43,9 @@ final class ViewFocusBinding {
3543 }
3644
3745 void changeViewFocus (int viewId, ui.ViewFocusState state) {
46+ if (! isEnabled) {
47+ return ;
48+ }
3849 final DomElement ? viewElement = _viewManager[viewId]? .dom.rootElement;
3950
4051 if (state == ui.ViewFocusState .focused) {
@@ -69,6 +80,10 @@ final class ViewFocusBinding {
6980 });
7081
7182 void _handleFocusChange (DomElement ? focusedElement) {
83+ if (! isEnabled) {
84+ return ;
85+ }
86+
7287 final int ? viewId = _viewId (focusedElement);
7388 if (viewId == _lastViewId) {
7489 return ;
Original file line number Diff line number Diff line change @@ -17,14 +17,18 @@ void testMain() {
1717 late EnginePlatformDispatcher dispatcher;
1818
1919 setUp (() {
20- domDocument.activeElement? .blur ();
21- EngineSemantics .instance.semanticsEnabled = false ;
20+ ViewFocusBinding .isEnabled = true ;
2221
2322 dispatcher = EnginePlatformDispatcher .instance;
2423 dispatchedViewFocusEvents = < ui.ViewFocusEvent > [];
2524 dispatcher.onViewFocusChange = dispatchedViewFocusEvents.add;
2625 });
2726
27+ tearDown (() {
28+ ViewFocusBinding .isEnabled = false ;
29+ EngineSemantics .instance.semanticsEnabled = false ;
30+ });
31+
2832 test ('The view is focusable and reachable by keyboard when registered' , () async {
2933 final EngineFlutterView view = createAndRegisterView (dispatcher);
3034
You can’t perform that action at this time.
0 commit comments