Skip to content

Conversation

@gspencergoog
Copy link
Contributor

@gspencergoog gspencergoog commented Feb 5, 2024

Description

This causes the Focus widget to request focus on its focus node if the accessibility system (screen reader) focuses a widget via the SemanticsAction.focus action.

Related Issues

Tests

  • Added a test to make sure that focus is requested when SemanticsAction.focus is sent by the engine.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: focus Focus traversal, gaining or losing focus labels Feb 5, 2024
@gspencergoog gspencergoog requested a review from yjbanov February 5, 2024 20:29
@goderbauer
Copy link
Member

This change surprised me. At least on Android (and I think on iOS as well) a11y focus and input focus are two separate concepts and you can totally move a11y focus away from e.g. a textfield while the textfield retains input focus.

@yjbanov
Copy link
Contributor

yjbanov commented Feb 27, 2024

This change surprised me. At least on Android (and I think on iOS as well) a11y focus and input focus are two separate concepts and you can totally move a11y focus away from e.g. a textfield while the textfield retains input focus.

This is a good point. This behavior should be limited to desktop form factor. It is true that on mobile accessibility focus does not automatically grab the input focus. On desktop (at least I tried on macOS, and desktop web) it does.

@goderbauer
Copy link
Member

On desktop (at least I tried on macOS, and desktop web) it does.

How do on screen IMEs work on Desktop in a11y mode if moving the a11y focus to a key on the onscreen keyboard removes the input focus from the textfield you want to type into?

@yjbanov
Copy link
Contributor

yjbanov commented Feb 27, 2024

Haven't tried IMEs specifically, but moving accessibility into a different text fields does stop editing the previous field and starts editing the newly focused field.

@gspencergoog
Copy link
Contributor Author

Is there an actual user of this UI that we can ask about this behavior? It does seem like we're making a change to a UX experience that we don't really use ourselves. I'd hate to mess with the accessibility system's usability without checking in with at least one actual user.

@gspencergoog gspencergoog force-pushed the focus_on_a11y_focus branch from 8bd671c to 7f94913 Compare May 31, 2024 22:31
@gspencergoog gspencergoog marked this pull request as ready for review May 31, 2024 22:31
@github-actions github-actions bot added the a: tests "flutter test", flutter_test, or one of our tests label May 31, 2024
@gspencergoog
Copy link
Contributor Author

Okay, I think this is updated to match Yegor's change. I added in some missing matchers for the semantics testing too.

@github-actions github-actions bot added a: text input Entering text in a text field or keyboard related problems f: material design flutter/packages/flutter/material repository. a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) f: cupertino flutter/packages/flutter/cupertino repository f: routes Navigator, Router, and related APIs. labels May 31, 2024
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be _couldRequestFocus ? focusNode.requestFocus : null? It's strange that the condition that controls the availability of the onFocus callback is not exactly the same as the one used to control the focusable property below. If the two disagree, we could end up in a situation where the semantics thinks a widget is focusable while the framework does not, or vice versa.

If it is important to use separate conditions, it would also be good to have a test that covers it, and I may have to change my engine PR to do the right thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's much clearer. In reality, it makes no difference, since _couldRequestFocus is just equal to focusNode.canRequestFocus, and the requestFocus method exits early if the node already has focus.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment still refers to "accessibility focus". Since we switched from didGainAccessibilityFocus to focus, it should say just "focus", or to be more precise "input focus request from semantics".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, fixed.

@zywek123
Copy link

zywek123 commented Jun 3, 2024

Perhaps this solved the problem with the accessibility of the edit fields?
Previously as now in the stable version of flutter 3.22, placing your finger on the edit box on iOS with VoiceOver enabled and lifting your finger caused the edit box to expand and show the keyboard, which shouldn't happen. In the latest master 30 minutes ago, this behaviour was fixed.

@gspencergoog gspencergoog force-pushed the focus_on_a11y_focus branch from 18e0c7a to 3c36672 Compare June 3, 2024 16:01
@gspencergoog
Copy link
Contributor Author

Perhaps this solved the problem with the accessibility of the edit fields?

Unlikely, since this PR hasn't landed yet. But if it's fixed, we'll try not to break it with this PR.

@gspencergoog gspencergoog force-pushed the focus_on_a11y_focus branch from 3c36672 to d6d2625 Compare June 3, 2024 16:05
@gspencergoog gspencergoog added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 3, 2024
@auto-submit
Copy link
Contributor

auto-submit bot commented Jun 3, 2024

auto label is removed for flutter/flutter/142942, due to - The status or check suite Mac framework_tests_impeller 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 Jun 3, 2024
Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

auto-submit bot pushed a commit that referenced this pull request Jun 5, 2024
@auto-submit auto-submit bot removed the revert Autorevert PR (with "Reason for revert:" comment) label Jun 5, 2024
auto-submit bot added a commit that referenced this pull request Jun 5, 2024
…ble widget (#142942)" (#149741)

Reverts: #142942
Initiated by: zanderso
Reason for reverting: Seems to have affected iOS platform view focus: https://ci.chromium.org/ui/p/flutter/builders/prod/Mac_ios%20native_platform_view_ui_tests_ios/10626/overview
Original PR Author: gspencergoog

Reviewed By: {yjbanov, goderbauer, chunhtai}

This change reverts the following previous change:
## Description

This causes the `Focus` widget to request focus on its focus node if the accessibility system (screen reader) focuses a widget via the `SemanticsAction.focus` action.

## Related Issues
 - #83809

## Tests
 - Added a test to make sure that focus is requested when `SemanticsAction.focus` is sent by the engine.
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 5, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 5, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 5, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 5, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Jun 5, 2024
flutter/flutter@c246ecd...27e0656

2024-06-05 98614782+auto-submit[bot]@users.noreply.github.com Reverts "TreeSliver & associated classes (#147171)" (flutter/flutter#149754)
2024-06-05 p.trost93@gmail.com Feature: Add AnimatedList with separators (flutter/flutter#144899)
2024-06-05 yjbanov@google.com make output of flutter run web tests verbose (flutter/flutter#149694)
2024-06-05 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Request focus if `SemanticsAction.focus` is sent to a focusable widget (#142942)" (flutter/flutter#149741)
2024-06-05 engine-flutter-autoroll@skia.org Roll Flutter Engine from e88469090fed to 11a32d43e3f6 (2 revisions) (flutter/flutter#149699)
2024-06-05 gspencergoog@users.noreply.github.com Request focus if `SemanticsAction.focus` is sent to a focusable widget (flutter/flutter#142942)
2024-06-04 engine-flutter-autoroll@skia.org Roll Flutter Engine from 3dd40156afb6 to e88469090fed (2 revisions) (flutter/flutter#149695)
2024-06-04 katelovett@google.com TreeSliver & associated classes (flutter/flutter#147171)
2024-06-04 engine-flutter-autoroll@skia.org Roll Flutter Engine from fe00f023666c to 3dd40156afb6 (3 revisions) (flutter/flutter#149692)
2024-06-04 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 3.25.7 to 3.25.8 (flutter/flutter#149691)
2024-06-04 47866232+chunhtai@users.noreply.github.com Prepares semantics_update_test for upcoming heading level changes (flutter/flutter#149671)
2024-06-04 34871572+gmackall@users.noreply.github.com Identify and re-throw our dependency checking errors in `flutter.groovy` (flutter/flutter#149609)
2024-06-04 hans.muller@gmail.com Scrollbar thumb drag gestures now produce one start and one end scroll notification (flutter/flutter#146654)
2024-06-04 15619084+vashworth@users.noreply.github.com Disable sandboxing for macOS apps and tests in CI (flutter/flutter#149618)
2024-06-04 engine-flutter-autoroll@skia.org Roll Flutter Engine from e211c43f3dc1 to fe00f023666c (3 revisions) (flutter/flutter#149680)
2024-06-04 gspencergoog@users.noreply.github.com Allow `find.byTooltip` to use a RegEx (flutter/flutter#149348)
2024-06-04 engine-flutter-autoroll@skia.org Roll Flutter Engine from a6aa5d826649 to e211c43f3dc1 (8 revisions) (flutter/flutter#149658)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC dit@google.com,rmistry@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: 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
gspencergoog added a commit to gspencergoog/flutter that referenced this pull request Jun 6, 2024
Reland: Request focus if SemanticsAction.focus is sent to a focusable widget (flutter#142942)
gspencergoog added a commit to gspencergoog/flutter that referenced this pull request Jun 12, 2024
Reland: Request focus if SemanticsAction.focus is sent to a focusable widget (flutter#142942)
auto-submit bot pushed a commit that referenced this pull request Jun 12, 2024
…et (#142942) (#149840)

## Description

This attempts to re-land #142942 after being reverted in #149741 because it broke the iOS [platform view UI integration test](https://github.com/flutter/flutter/blob/master/dev/integration_tests/ios_platform_view_tests/ios/PlatformViewUITests/PlatformViewUITests.m?rgh-link-date=2024-06-06T19%3A47%3A27Z).

The changes here from the original are that in the Focus widget we no longer set the `onFocus` for the `Semantics` if the platform is iOS.  It was not intended to do anything on iOS anyhow.

Also, I updated the matchers to not actually do anything yet with the SemanticsAction.focus matching, so that this can be landed without breaking customer tests, and once they have been updated to correctly look for the focus action, we can land a PR that will turn it on.

## Related Issues
 - #149838
 - #83809
 - #149842

## Tests
 - Updated framework tests to look for the appropriate things using the matchers, even though it doesn't actually test for them yet.
victorsanni pushed a commit to victorsanni/flutter that referenced this pull request Jun 14, 2024
…et (flutter#142942) (flutter#149840)

## Description

This attempts to re-land flutter#142942 after being reverted in flutter#149741 because it broke the iOS [platform view UI integration test](https://github.com/flutter/flutter/blob/master/dev/integration_tests/ios_platform_view_tests/ios/PlatformViewUITests/PlatformViewUITests.m?rgh-link-date=2024-06-06T19%3A47%3A27Z).

The changes here from the original are that in the Focus widget we no longer set the `onFocus` for the `Semantics` if the platform is iOS.  It was not intended to do anything on iOS anyhow.

Also, I updated the matchers to not actually do anything yet with the SemanticsAction.focus matching, so that this can be landed without breaking customer tests, and once they have been updated to correctly look for the focus action, we can land a PR that will turn it on.

## Related Issues
 - flutter#149838
 - flutter#83809
 - flutter#149842

## Tests
 - Updated framework tests to look for the appropriate things using the matchers, even though it doesn't actually test for them yet.
victorsanni pushed a commit to victorsanni/flutter that referenced this pull request Jun 14, 2024
…et (flutter#142942) (flutter#149840)

## Description

This attempts to re-land flutter#142942 after being reverted in flutter#149741 because it broke the iOS [platform view UI integration test](https://github.com/flutter/flutter/blob/master/dev/integration_tests/ios_platform_view_tests/ios/PlatformViewUITests/PlatformViewUITests.m?rgh-link-date=2024-06-06T19%3A47%3A27Z).

The changes here from the original are that in the Focus widget we no longer set the `onFocus` for the `Semantics` if the platform is iOS.  It was not intended to do anything on iOS anyhow.

Also, I updated the matchers to not actually do anything yet with the SemanticsAction.focus matching, so that this can be landed without breaking customer tests, and once they have been updated to correctly look for the focus action, we can land a PR that will turn it on.

## Related Issues
 - flutter#149838
 - flutter#83809
 - flutter#149842

## Tests
 - Updated framework tests to look for the appropriate things using the matchers, even though it doesn't actually test for them yet.
auto-submit bot pushed a commit that referenced this pull request Jun 27, 2024
Adds `onFocus` support to Cupertino and Material text field widgets (similar to #142942).
victorsanni pushed a commit to victorsanni/flutter that referenced this pull request Jul 8, 2024
Adds `onFocus` support to Cupertino and Material text field widgets (similar to flutter#142942).
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) a: tests "flutter test", flutter_test, or one of our tests a: text input Entering text in a text field or keyboard related problems autosubmit Merge PR when tree becomes green via auto submit App f: cupertino flutter/packages/flutter/cupertino repository f: focus Focus traversal, gaining or losing focus f: material design flutter/packages/flutter/material repository. f: routes Navigator, Router, and related APIs. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants