Repository navigation
Use live region in error text input decorator for Android - #165531
Conversation
|
The original issue #99715 is not on android but on macOS with voiceover, can you test if the live region works there? |
Looks like macos has issues with liveregion and not speaking this text. Does macos not support liveregion at all? |
e58f957 to
675d730
Compare
804b5d4 to
248d5ab
Compare
I added back the original code for the other platforms and turned on liveRegion and removed the deprecated announce call for Android. |
7da36ca to
509583c
Compare
| } | ||
|
|
||
| if (errorMessage.isNotEmpty) { | ||
| if (errorMessage.isNotEmpty && defaultTargetPlatform != TargetPlatform.android) { |
There was a problem hiding this comment.
can you add a comment here that android is use live region for error message and others are using announcement?
There was a problem hiding this comment.
Can you instead refactor this into a method named "shouldPreferLiveRegionOverAnnounce"
There was a problem hiding this comment.
I ended up choosing to go with isAnnounceSupported because live region would probably not be the best replacement all the time. The PR for that is in #166099
There was a problem hiding this comment.
@reidbaker this PR can be reviewed now since the parent PR was merged
reidbaker
left a comment
There was a problem hiding this comment.
Please also update the pr description with the current state of the pr. (forked behavior instead of a pure revert)
@ash2moon see https://docs.flutter.dev/ui/adaptive-responsive/capabilities for a longer set of documenation on my thoughts behind why we should abstract the logic around platform checking to a method.
| } | ||
|
|
||
| if (errorMessage.isNotEmpty) { | ||
| if (errorMessage.isNotEmpty && defaultTargetPlatform != TargetPlatform.android) { |
There was a problem hiding this comment.
Can you instead refactor this into a method named "shouldPreferLiveRegionOverAnnounce"
Made this PR to resolve this issue: I'll update the code in this PR once that one is merged. |
509583c to
d2d38d9
Compare
5347271 to
20db932
Compare
<!-- Thanks for filing a pull request! Reviewers are typically assigned within a week of filing a request. To learn more about code review, see our documentation on Tree Hygiene: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md --> Helps unblock #165531 and is part of #165510 *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* ## 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
| /// announcements are generally supported without discouragement. | ||
| /// | ||
| /// Use this flag to conditionally avoid making announcements on Android. | ||
| bool get noAnnounce => _kNoAnnounceIndex & _index != 0; |
There was a problem hiding this comment.
This is a relatively minor issue, and if you've already discussed this with others more knowledgable of a11y work feel free to disregard - but the negative qualifier no is sort of confusing (to me), at least after reading the description:
/// Returns `false` on all other platforms (iOS, web, desktop) where such /// announcements are generally supported without discouragement.
I'd expect to see something like:
/// Whether accessibility announcements (like [SemanticsService.announce])
/// are encouraged on the current platform.
///
/// Returns `false` on Android, where platform announcements are deprecated
/// by the underlying platform.
///
/// Returns `true` on all other platforms (iOS, web, desktop) where such
/// announcements are generally supported without discouragement.
///
/// Use this flag to conditionally make announcements.
bool get announce => _kAnnounceIndex & _index != 0;There was a problem hiding this comment.
The issue with positive notion is that for most platform it will be true. This may break exisiting embedder because this is a bit map and default value is 0.
There was a problem hiding this comment.
We could rephrase it to be positive for example preferLiveRegion. That said I think we are not actually preferring live region but instead discouraging announce.
There was a problem hiding this comment.
I mean a cheap option is just bool get announce => _kAnnounceIndex & _index == 0.
Anyway, just trying to get ahead of understanding:
if (!noAnnounce) { /* ... */ }There was a problem hiding this comment.
That sounds like a pretty good solution. Just gotta add some comments explaining that this is intentional and not a bug.
There was a problem hiding this comment.
How about we use _kNoAnnounceIndex for the embedder and announce for the API?
That way we can avoid confusion?
There was a problem hiding this comment.
I care a lot less about the implementation detail, so SGTM
…/use-liveregion-form
|
Just did my final round of testing on two real devices and made sure the media queries and announcement forking logic works well. |
|
autosubmit label was removed for flutter/flutter/165531, because - The status or check suite Linux linux_web_engine_tests has failed. Please fix the issues identified (or deflake) before re-applying this label.
|
|
reason for revert: Breaks google client tests |
Resolves partly #165510
Context: This issue originates from #99715, where it was reported that
liveRegionalone was insufficient for announcing form validation errors. WhileliveRegionannounces the first error encountered, subsequent submissions with the same error message on Android would not trigger a re-announcement.Original Solution: Pull request #123373 addressed this by implementing the
announceevent to ensure error messages were consistently announced, even for repeated submissions.Native Android Behavior (Jetpack Compose): In native Android development using Jetpack Compose, setting the
isErrorproperty of aTextFieldtotruetriggers Talkback to announce "Error invalid input." This announcement occurs only on the initial change to the error state. Subsequent errors, even if theisErrorproperty remainstrue, are not re-announced. This behavior closely mirrors the functionality ofliveRegion, with the key difference being thatliveRegionalso announces the specific error text, in addition to the general error state. Testing in a native Jetpack Compose application confirms this behavior and provides a valuable comparison point against the current Flutter form example.Suggested Action: Fork the behavior in #123373. Reinstate the use of
liveRegionfor error announcements withinwidgets/Formfor Android and keep other platforms the same.Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.