Skip to content

Add back "Use live region in error text input decorator for Android #165531" #168992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

ash2moon
Copy link
Contributor

@ash2moon ash2moon commented May 16, 2025

Partly of #165510

⤴️ Parent PR: #169685 (✅ Merged)
⤴️ Parent PR (refactor): #170618 (⏹️ Pending)

Re-lands #165531
The PR was originally reverted due to an issue with an internal Google test. I added a new test case under input_decorator_test.dart which does something similar to prevent the regression. All other code is the same as #165531.

The easiest way to review this would probably be to just check the diff after the first commit to see the changes I made. To check if the reland commit is the same, it might be best to just compare solely that commit against the original PR.

Pre-launch Checklist

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

@github-actions github-actions bot added a: tests "flutter test", flutter_test, or one of our tests a: text input Entering text in a text field or keyboard related problems platform-android Android applications specifically framework flutter/packages/flutter repository. See also f: labels. engine flutter/engine repository. See also e: labels. f: material design flutter/packages/flutter/material repository. a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) platform-web Web applications specifically labels May 16, 2025
@ash2moon ash2moon force-pushed the feat/form-live-region branch from 7f6df3d to 9bd8d56 Compare May 16, 2025 18:23
@ash2moon ash2moon force-pushed the feat/form-live-region branch from ec61f12 to cb5647c Compare May 18, 2025 03:52
@matanlurey matanlurey removed their request for review May 19, 2025 22:27
@ash2moon
Copy link
Contributor Author

Hey @ash2moon, some of the CI patterns in this PR are surprising to me.

Can you take a look at flutter.dev/to/ci-yaml and see if these situations might apply to your PR? I'd expect a lot less Merge branch 'master' into ..., but maybe you're hitting a situation I don't know about.

It doesn't seem like it's any of those issues. Most of my merges were because the tree was blocked, and I had to update my branch to the latest version to check if the tree would be fixed. Another recurring issue I noticed was that the Google Testing job would sometimes delete the CL and rerunning the test wouldn't actually do anything different.

I only just found out about rerunning tests through Luci though, so I'll be doing that instead for any future flaky tests.

@ash2moon ash2moon added the autosubmit Merge PR when tree becomes green via auto submit App label May 29, 2025
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 29, 2025
Copy link
Contributor

auto-submit bot commented May 29, 2025

autosubmit label was removed for flutter/flutter/168992, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@@ -968,6 +969,20 @@ class AccessibilityFeatures {
/// Only supported on iOS.
bool get onOffSwitchLabels => _kOnOffSwitchLabelsIndex & _index != 0;

/// Whether accessibility announcements (like [SemanticsService.announce])
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we get rid of the like? or if there is some fuzziness can you articulate more clearly what else would match?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is technically another way to send an announcement but it is much less common and that is by sending an announcement event over the system channel directly.

@@ -968,6 +969,20 @@ class AccessibilityFeatures {
/// Only supported on iOS.
bool get onOffSwitchLabels => _kOnOffSwitchLabelsIndex & _index != 0;

/// Whether accessibility announcements (like [SemanticsService.announce])
/// are allowed on the current platform.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// are allowed on the current platform.
/// are encouraged on the current platform.

right now announce is discouraged but possible on android 36.

Copy link
Contributor Author

@ash2moon ash2moon May 29, 2025

Choose a reason for hiding this comment

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

I think the accessibility team discourages using announcements in general. Should we keep it as supports in that case?

Copy link
Contributor

Choose a reason for hiding this comment

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

The android accessibility team discourages announcements other accessability teams have the api and have no issue. Think about this documentation from the callers perspective. Is this value about if you can use announcements? I think not because technically they can work until it is just discourage because they want to turn off the api. Is this value about if you should or if it is encouraged or if it is some other word? But make the value have predictable meaning to a new situation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, sorry I meant that the Flutter accessibility team also discourages announcements too. @chunhtai for more input on announce usage in Flutter. I'm thinking that supportsAnnounce would be the best because if Android ever removes announce support, then supportsAnnounce can still just be false and developer's can continue to rely on their branched logic.

Copy link
Contributor

@chunhtai chunhtai Jun 13, 2025

Choose a reason for hiding this comment

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

I think Android team is meant to remove the API at some point, so I think having a more definite language here is more future proof.

Flutter accessibility team also discourages announcements too

I don't think we have an opinion on this. This is per platform decision, we have to follow each platform so that flutter app in that platform won't create a different user experience.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay gotcha. I'm leaning towards using supports in the docs here then. Also see similar comment here for reasoning: #168992 (comment)

@@ -115,6 +115,7 @@ abstract class AccessibilityFeatures {
bool get reduceMotion;
bool get highContrast;
bool get onOffSwitchLabels;
bool get announce;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it is too late but it feels like announce needs a modifier. Like prefer or should and that announce alone is confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking something like supportsAnnounce. How's that sound?

Copy link
Contributor

Choose a reason for hiding this comment

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

Q: "How strongly do you feel about that change? ... no other method there is using a prefix and the class name implies these are feature flags "

The name does seem to imply a prefix but I am struggling to guess at the prefix.
For example:
Is the prefix can-InvertColors or should-InvertColors or userPrefers-InvertColors phoneHas-InvertColorsOption.
Same with disableAnimations, can-DisableAnimations does not make sense should-DisableAnimations and userPrefers-DisabledAnimations could make sense.

I think announce is even more difficult because with api 36 my understanding is not that it wont work but instead it should not be used. That subtly important especially since we have positive and negative versions of an announce boolean.

If we knew other platforms were going to also remove announce then I would say we should actualy create 2 booleans one for if it will work and the other for if it is not depreciated.

So renaming this variable is not blocking but resolving the confusion about the scope and what the booleans actually mean across the pr is blocking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense.

In that case I'm thinking that supportsAnnounce for now and if another platform does something different like encouragesAnnounce, we can add that later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm trying to come up with a proper name change and I'm leaning towards supportsAnnounce.

Reason to use supports: It would treat deprecated/removed use cases the same way and developers don't have to worry about potentially a future removal of the API as this will already count for it.
Reason not to use supports: If developers truly need announce, they would need to write a platform check to see if their specific platform simply discourages it but still has the capability.

Reason to use prefers: It allows developers to treat this flag as only a hint.
Reason not to use prefers: It's a bit misleading because then users would be tempted to use announce when other mechanisms like liveRegion would be more appropriate. Even iOS (see docs discourages use when elements are changing too frequently.

Copy link
Contributor Author

@ash2moon ash2moon Jun 13, 2025

Choose a reason for hiding this comment

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

I ended up choosing to go with supportsAnnounce. This will require some refactoring in the engine before this PR lands. See PR: 170618

@@ -584,6 +589,23 @@ class MediaQueryData {
/// originates.
final bool boldText;

/// Whether accessibility announcements (like [SemanticsService.announce])
/// are allowed on the current platform.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// are allowed on the current platform.
/// are encouraged on the current platform.

Copy link
Contributor Author

@ash2moon ash2moon Jun 9, 2025

Choose a reason for hiding this comment

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

How about "supported"? Flutter does not really encourage using announcements.

ash2moon added a commit to ash2moon/flutter that referenced this pull request May 29, 2025
ash2moon added a commit to ash2moon/flutter that referenced this pull request May 29, 2025
github-merge-queue bot pushed a commit that referenced this pull request Jun 3, 2025
Partly of #165510

⤵️ Child PR: #168992

Partly re-lands #165531
The PR was originally reverted due to an issue with an internal Google
test. I split re-land PR into two separate ones so that we can
individually revert in case it fails again.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
ash2moon added 2 commits June 9, 2025 15:19
…/form-live-region

# Conflicts:
#	engine/src/flutter/lib/ui/window.dart
#	engine/src/flutter/lib/web_ui/lib/src/engine/semantics/semantics.dart
@github-actions github-actions bot removed a: tests "flutter test", flutter_test, or one of our tests platform-android Android applications specifically engine flutter/engine repository. See also e: labels. platform-web Web applications specifically labels Jun 9, 2025
@github-actions github-actions bot added engine flutter/engine repository. See also e: labels. platform-web Web applications specifically labels Jun 13, 2025
@github-actions github-actions bot added the a: tests "flutter test", flutter_test, or one of our tests label Jun 13, 2025
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 engine flutter/engine repository. See also e: labels. f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. platform-web Web applications specifically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants