Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@tugorez
Copy link
Contributor

@tugorez tugorez commented Feb 22, 2024

Mark the Flutter View as focusable by setting a tabindex value.

  • 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
  • When semantics are enabled no tabindex will be set.

Relevant Issues are:

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added the platform-web Code specifically for the web engine label Feb 22, 2024
@tugorez tugorez changed the title [WIP] Works with semantics Marks the Flutter Views as focusable. Feb 23, 2024
@tugorez tugorez changed the title Marks the Flutter Views as focusable. Marks the Flutter Views as focusable by setting a tabindex value. Feb 23, 2024
@tugorez tugorez marked this pull request as ready for review February 23, 2024 00:45
@tugorez tugorez requested review from ditman and yjbanov February 23, 2024 00:46
Copy link
Member

@ditman ditman left a 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)

});
}

EngineFlutterView createAndRegisterView(EnginePlatformDispatcher dispatcher) {
Copy link
Member

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)

Copy link
Contributor Author

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?

Copy link
Contributor Author

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!


late final ViewFocusBinding _viewFocusBinding = ViewFocusBinding(
viewManager: viewManager,
onViewFocusChange: invokeOnViewFocusChange,
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

@ditman ditman Feb 23, 2024

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 EnginePlatformDispatcher only on FlutterViewFocusManager

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

@tugorez tugorez requested a review from ditman February 23, 2024 04:17
@tugorez tugorez changed the title Marks the Flutter Views as focusable by setting a tabindex value. Mark the Flutter Views as focusable by setting a tabindex value. Feb 23, 2024
Copy link
Contributor

@yjbanov yjbanov left a 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

@ditman
Copy link
Member

ditman commented Feb 24, 2024

(Holding off on reviewing this, @tugorez might want to tweak some odds and ends, will follow up with him next week! Thanks for the feature @tugorez!!)

@tugorez
Copy link
Contributor Author

tugorez commented Feb 26, 2024

Without these changes: https://flutterwebaccesibility2.web.app/
With these changes: https://flutter-web-20c94.web.app/

}

void _handleViewCreated(int viewId) {
_markViewAsFocusable(viewId, reachableByKeyboard: true);
Copy link
Member

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.

Copy link
Member

@ditman ditman left a 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!

@tugorez
Copy link
Contributor Author

tugorez commented Feb 28, 2024

I made some changes.

@ditman
Copy link
Member

ditman commented Feb 29, 2024

@tugorez you're still testing with platform views, right?

@tugorez
Copy link
Contributor Author

tugorez commented Feb 29, 2024

@tugorez you're still testing with platform views, right?

Waiting on a final extra review from @yjbanov to make sure my changes don't break semantics.

@ditman
Copy link
Member

ditman commented Mar 6, 2024

I made some changes.

Took a look with VoiceOver, and both apps seem to work the same for me. Let's merge this!

@tugorez
Copy link
Contributor Author

tugorez commented Mar 8, 2024

Let's land this PR as is and follow up with the multiview verification in flutter/flutter#144853

@tugorez tugorez added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 8, 2024
@auto-submit
Copy link
Contributor

auto-submit bot commented Mar 8, 2024

auto label is removed for flutter/engine/50876, due to Pull request flutter/engine/50876 is not in a mergeable state.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Mar 8, 2024
@tugorez tugorez added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 8, 2024
@auto-submit
Copy link
Contributor

auto-submit bot commented Mar 8, 2024

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.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Mar 8, 2024
@tugorez tugorez added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 8, 2024
@auto-submit auto-submit bot merged commit 767c25d into flutter:main Mar 8, 2024
@ditman
Copy link
Member

ditman commented Mar 9, 2024

Let's go @tugorez!!

engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 9, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Mar 9, 2024
…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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App platform-web Code specifically for the web engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants