a11y: expose max character count for text fields#12269
a11y: expose max character count for text fields#12269goderbauer merged 4 commits intoflutter:masterfrom
Conversation
| } | ||
| result.setMovementGranularities(granularities); | ||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && semanticsNode.maxValueLength != -1) { | ||
| result.setMaxTextLength(semanticsNode.maxValueLength); |
There was a problem hiding this comment.
Please double check the behavior here with non-english texts + emojis. We might need to massage the data from codePoints to graphemes or characters
There was a problem hiding this comment.
Of course this is complicated: Flutter expresses its character count as number of Unicode scalar values that are allowed (which has its own limitations, see https://master-api.flutter.dev/flutter/material/TextField/maxLength.html). Android on the other hand encodes the content of the text field with utf16 and counts the number of bytes. So the American Flag emoji has a length of 2 in Flutter, but a length of 4 for Android. A regular human being would probably consider that thing to just be one character...
Anyways, not sure how to resolve this. I'll do some more research.
There was a problem hiding this comment.
I thought about this some more. I think we really want to avoid the situation where the character counter on the flutter side is wildly out of sync with the character counter on the native side. It sounds like this would be the case with this change and there isn't much we can do about it, given that we don't control how Android/Talkback count characters.
There was a problem hiding this comment.
unless of course we could either trick Android into thinking we had a specific number of characters, or adjusted our character count to be (more?) broken
There was a problem hiding this comment.
I added another property "currentValueLength" which contains what the framework currently things the length of the entered text is. I am using this one to adjust the max value if android and flutter disagree on the size of the text. While the max value reported to android can now change depending on the characters you enter, it works great with talkback and talkback announces at the correct point that the maximum has been reached.
| /// string describes what result an action performed on this node has. The | ||
| /// reading direction of all these strings is given by `textDirection`. | ||
| /// | ||
| /// The fields 'textSelectionBase' and 'textSelectionExtent' describe the |
There was a problem hiding this comment.
This needs to be added to the web_ui implementation too
[email protected]:flutter/engine.git/compare/04f567bdde40...2c4ed36 git log 04f567b..2c4ed36 --no-merges --oneline 2019-09-16 [email protected] Roll src/third_party/dart a8f433820b..7799f424f4 (3 commits) 2019-09-16 [email protected] a11y: expose max character count for text fields (flutter/engine#12269) 2019-09-16 [email protected] Roll src/third_party/skia 86c48abc94f3..c22498502cda (1 commits) (flutter/engine#12300) 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] on the revert to ensure that a human is aware of the problem. To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md
[email protected]:flutter/engine.git/compare/04f567bdde40...2c4ed36 git log 04f567b..2c4ed36 --no-merges --oneline 2019-09-16 [email protected] Roll src/third_party/dart a8f433820b..7799f424f4 (3 commits) 2019-09-16 [email protected] a11y: expose max character count for text fields (flutter/engine#12269) 2019-09-16 [email protected] Roll src/third_party/skia 86c48abc94f3..c22498502cda (1 commits) (flutter/engine#12300) 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] on the revert to ensure that a human is aware of the problem. To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md
Wire up Android's setMaxTextLength to communicate the number of characters a user can input into a text field to a11y users.
Work towards flutter/flutter#38940