-
Notifications
You must be signed in to change notification settings - Fork 6k
Mark the Flutter Views as focusable by setting a tabindex value. #50876
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The stuff we've been talking about lately about the other bindings lacking instrumentation so they could be used from this one kind of informed this review.
I think the coolest change to this would be to stop receiving a singular "onViewFocusChanged" callback, and instead, expose a Stream of ViewFocusChanged events from here; that way, the class becomes more decoupled from how it's going to be used by the PlatformDispatcher (or the tests)
lib/web_ui/lib/src/engine/platform_dispatcher/view_focus_binding.dart
Outdated
Show resolved
Hide resolved
lib/web_ui/lib/src/engine/platform_dispatcher/view_focus_binding.dart
Outdated
Show resolved
Hide resolved
| }); | ||
| } | ||
|
|
||
| EngineFlutterView createAndRegisterView(EnginePlatformDispatcher dispatcher) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How many times is this function duplicated in tests? It looks familiar! (I wonder if it'd make sense to start creating a collection of these helpers so they can be reused across the engine tests)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any advice on where it should go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to address this in a follow up PR!
lib/web_ui/lib/src/engine/platform_dispatcher/view_focus_binding.dart
Outdated
Show resolved
Hide resolved
|
|
||
| late final ViewFocusBinding _viewFocusBinding = ViewFocusBinding( | ||
| viewManager: viewManager, | ||
| onViewFocusChange: invokeOnViewFocusChange, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this class exposed a stream of events, then you don't need to pass the onViewFocusChange through its constructor, and the viewManager can default to EnginePlatformDispatcher.instance.viewManager, so ViewFocusBinding can become a singleton again :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmmm I find a bit weird the fact that EnginePlatformDispatcher depends on ViewFocusBinding and viceversa.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
? It already depends on it, I'm just saying that instead of:
final _viewFocusBinding = ViewFocusBinding(
viewManager: viewManager,
onViewFocusChange: invokeOnViewFocusChange,
)you do:
final _viewFocusBinding = ViewFocusBinding(
viewManager: viewManager,
); // or: ViewFocusBinding.instance;
// elsewhere
_viewFocusBinding.onViewFocusChange.listen((ViewFocusChange event) {
// Do whatever we need with the event now...
});That way you don't need to pass a tear-off into the ViewFocusBinding instance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
? It already depends on it, I'm just saying that instead of:
How so? The view focus binding class doesn't have any dependencies on EnginePlatformDispatcher only on FlutterViewFocusManager
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The view focus binding class doesn't have any dependencies on
EnginePlatformDispatcheronly onFlutterViewFocusManager
Could you create the view focus binding class outside of the EnginePlatformDispatcher, without using the EnginePlatformDispatcher (to retrieve the viewManager)? I think that's a fairly strong dependency :P
lib/web_ui/lib/src/engine/platform_dispatcher/view_focus_binding.dart
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if LGT @ditman
lib/web_ui/lib/src/engine/platform_dispatcher/view_focus_binding.dart
Outdated
Show resolved
Hide resolved
|
Without these changes: https://flutterwebaccesibility2.web.app/ |
| } | ||
|
|
||
| void _handleViewCreated(int viewId) { | ||
| _markViewAsFocusable(viewId, reachableByKeyboard: true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we were to listen to focusin/out, we'd need to use this method to attach listener to new views.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM, but I'd like the focusin/out events to be attached to the rootElements of the views, if technically possible. I think that'd simplify this code a good bit!
|
I made some changes.
|
|
@tugorez you're still testing with platform views, right? |
Took a look with VoiceOver, and both apps seem to work the same for me. Let's merge this! |
When a given flutter view is focused its tabindex will be -1 When a given flutter view is not focused its tabindex will be 0
|
Let's land this PR as is and follow up with the multiview verification in flutter/flutter#144853 |
|
auto label is removed for flutter/engine/50876, due to Pull request flutter/engine/50876 is not in a mergeable state. |
|
auto label is removed for flutter/engine/50876, due to - The status or check suite Linux linux_host_engine has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
Let's go @tugorez!! |
…144862) flutter/engine@953927e...7541e90 2024-03-08 [email protected] [Impeller] implement mask blur for textures (flutter/engine#51183) 2024-03-08 [email protected] Don't rely on dart binary on PATH in run_test.py (flutter/engine#51302) 2024-03-08 [email protected] Mark the Flutter Views as focusable by setting a tabindex value. (flutter/engine#50876) 2024-03-08 [email protected] Update the instructions for updating licenses. (flutter/engine#51297) 2024-03-08 [email protected] Optimize overlays in CanvasKit (flutter/engine#47317) 2024-03-08 [email protected] Roll Fuchsia Linux SDK from 5Ra_AjCji-uR1GaX7... to lAV5jgp4796siOZgI... (flutter/engine#51296) 2024-03-08 [email protected] [Impeller] Add the KHR prefix to existing swapchain utilities. (flutter/engine#51295) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from 5Ra_AjCji-uR to lAV5jgp4796s If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Mark the Flutter View as focusable by setting a tabindex value.
-10Relevant Issues are:
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.