Repository navigation
Commit d811479
authored
[VPAT] Expose a semantics text field value while it is not being edited (flutter#195445)
Fixes flutter#147200
## Problem
With semantics enabled, a text field's `<input>` only gets a value while
it is focused, because only the text editing strategy writes it. A field
that was never focused, such as a disabled field showing prefilled text,
exposes an empty value, so screen readers do not read its content. Two
tests pinned this with a TODO pointing at flutter#147200.
## Fix
`SemanticTextField` now copies the semantics value into its element when
the value changes and the field is not being edited. The active field is
left to the text editing strategy, obscured fields are skipped because
their semantics value is masked, and fields owned by an autofill group
are skipped. The two tests now check the real value, and new tests cover
disabled, multi-line, obscured, autofill-owned and updated values.
## Demo
Open the a11y_assessments text field page with semantics enabled and
move a screen reader to the second, disabled "Email" field.
Before: VoiceOver says "Email, dimmed, edit text" and never says "xyz".
The element's `value` is empty.
After: VoiceOver also reads "xyz", and the element has `value="xyz"`.
Console check:
`[...document.querySelectorAll('[data-semantics-role="text-field"]')].map(e
=> e.value)` returns `["", ""]` before and `["", "xyz"]` after.1 parent 1ea585c commit d811479
3 files changed
Lines changed: 82 additions & 10 deletions
File tree
- engine/src/flutter/lib/web_ui
- lib/src/engine/semantics
- test/engine/semantics
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
481 | 482 | | |
482 | 483 | | |
483 | 484 | | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
484 | 522 | | |
485 | 523 | | |
486 | 524 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3002 | 3002 | | |
3003 | 3003 | | |
3004 | 3004 | | |
3005 | | - | |
3006 | | - | |
3007 | | - | |
3008 | | - | |
3009 | | - | |
| 3005 | + | |
| 3006 | + | |
| 3007 | + | |
3010 | 3008 | | |
3011 | 3009 | | |
3012 | 3010 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 97 | + | |
| 98 | + | |
101 | 99 | | |
102 | 100 | | |
103 | 101 | | |
104 | 102 | | |
105 | | - | |
| 103 | + | |
106 | 104 | | |
107 | 105 | | |
108 | 106 | | |
| |||
156 | 154 | | |
157 | 155 | | |
158 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
159 | 195 | | |
160 | 196 | | |
161 | 197 | | |
| |||
0 commit comments