Repository navigation
Commit 2fd8904
authored
[web] Hide synthetic autofill inputs from assistive technology (flutter#195618)
Fixes flutter#195174
## Problem
With semantics enabled, the web engine keeps a hidden autofill form in
the page so the browser can autofill and save credentials. The synthetic
inputs in that form have no label and are not hidden from assistive
technology, so screen readers and checkers like axe find extra unnamed
text boxes holding the user's input. The form stays in the page for the
rest of the session.
## Fix
In semantics mode, synthetic autofill inputs now get
`aria-hidden="true"` and `tabIndex = -1` at both creation sites. Each
field is already exposed through its own semantics element, browser
autofill does not read ARIA, and the element being edited is never a
synthetic one. Without semantics the inputs are left as they are,
because password manager extensions fill them and some skip
`aria-hidden` inputs.
## Demo
Before: https://flutter-demo-88-before.web.app
After: https://flutter-demo-88-after.web.app
Type in Username and Password, then press "Inspect hidden form". Before,
both hidden inputs are exposed and the accessibility tree has two
unnamed text boxes. After, they are `aria-hidden` and only the two real
fields are exposed.
## Verification
Tested in Chrome, before and after this change, with semantics on and
off:
| | Semantics on | Semantics off |
|---|---|---|
| Before | https://flutter-demo-88-before.web.app |
https://flutter-demo-88-before.web.app/?semantics=off |
| After | https://flutter-demo-88-after.web.app |
https://flutter-demo-88-after.web.app/?semantics=off |
Type a username and password, press Sign in, which calls
`TextInput.finishAutofillContext()`, and save the credential. Then
reload and pick the saved credential.
- Credential save: Chrome saves the typed username and password in all
four cases.
- Autofill: selecting the saved credential fills both Username and
Password in all four cases.1 parent e467dec commit 2fd8904
3 files changed
Lines changed: 52 additions & 0 deletions
File tree
- engine/src/flutter/lib/web_ui
- lib/src/engine/text_editing
- test/engine
- semantics
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
463 | 463 | | |
464 | 464 | | |
465 | 465 | | |
| 466 | + | |
466 | 467 | | |
467 | 468 | | |
468 | 469 | | |
469 | 470 | | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
470 | 494 | | |
471 | 495 | | |
472 | 496 | | |
| |||
529 | 553 | | |
530 | 554 | | |
531 | 555 | | |
| 556 | + | |
532 | 557 | | |
533 | 558 | | |
534 | 559 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
931 | 931 | | |
932 | 932 | | |
933 | 933 | | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
934 | 958 | | |
935 | 959 | | |
936 | 960 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3825 | 3825 | | |
3826 | 3826 | | |
3827 | 3827 | | |
| 3828 | + | |
| 3829 | + | |
| 3830 | + | |
3828 | 3831 | | |
3829 | 3832 | | |
3830 | 3833 | | |
| |||
0 commit comments