Repository navigation
[VPAT] Declare input purpose on a11y_assessments text fields #13243
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
Changes from 5 commits
973f8e2
936fd93
e1a1c1c
c5b4f9f
0d8249d
0675f4b
d183171
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -37,23 +37,31 @@ class _MainWidget extends StatelessWidget { | |||||
| label: 'Input field with suffix @gmail.com', | ||||||
| child: const TextField( | ||||||
| key: Key('enabled text field'), | ||||||
| maxLines: null, | ||||||
| keyboardType: TextInputType.emailAddress, | ||||||
| autofillHints: <String>[AutofillHints.email], | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, I reproduced it. Dropped the suffix in 0675f4b: a fixed suffix means the field only takes the part before the @, which conflicts with autocomplete="email". #/text-form-field has the same pattern, so I'll clean that up separately. |
||||||
| decoration: InputDecoration( | ||||||
| labelText: 'Email', | ||||||
| suffixText: '@gmail.com', | ||||||
| hintText: 'Enter your email', | ||||||
| // The field is single-line, so let the hint wrap at large | ||||||
| // text scales, one line per word. | ||||||
| hintMaxLines: 3, | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The PR description states that
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to 3 in description section. |
||||||
| ), | ||||||
| ), | ||||||
| ), | ||||||
| Semantics( | ||||||
| label: 'Input field with suffix @gmail.com', | ||||||
| child: TextField( | ||||||
| key: const Key('disabled text field'), | ||||||
| maxLines: null, | ||||||
| keyboardType: TextInputType.emailAddress, | ||||||
| autofillHints: const <String>[AutofillHints.email], | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the Dart style guide, type arguments on collection literals should be omitted when they can be inferred from the context. Since
Suggested change
References
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keeping the explicit to match the surrounding code, which uses explicit collection types throughout ([...]), and existing material_ui usage such as autofillHints: const [...] in text_form_field_test.dart. |
||||||
| decoration: const InputDecoration( | ||||||
| labelText: 'Email', | ||||||
| suffixText: '@gmail.com', | ||||||
| hintText: 'Enter your email', | ||||||
| // The field is single-line, so let the hint wrap at large | ||||||
| // text scales, one line per word. | ||||||
| hintMaxLines: 3, | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The PR description states that
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to 3 in description section. |
||||||
| ), | ||||||
| enabled: false, | ||||||
| controller: TextEditingController(text: 'xyz'), | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -35,11 +35,13 @@ class _MainWidget extends StatelessWidget { | |||||
| children: const <Widget>[ | ||||||
| TextField( | ||||||
| key: Key('enabled password'), | ||||||
| autofillHints: <String>[AutofillHints.password], | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the Dart style guide, type arguments on collection literals should be omitted when they can be inferred from the context. Since
Suggested change
References
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keeping the explicit to match the surrounding code, which uses explicit collection types throughout ([...]), and existing material_ui usage such as autofillHints: const [...] in text_form_field_test.dart. |
||||||
| decoration: InputDecoration(labelText: 'Password'), | ||||||
| obscureText: true, | ||||||
| ), | ||||||
| TextField( | ||||||
| key: Key('disabled password'), | ||||||
| autofillHints: <String>[AutofillHints.password], | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the Dart style guide, type arguments on collection literals should be omitted when they can be inferred from the context. Since
Suggested change
References
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keeping the explicit to match the surrounding code, which uses explicit collection types throughout ([...]), and existing material_ui usage such as autofillHints: const [...] in text_form_field_test.dart. |
||||||
| decoration: InputDecoration(labelText: 'Password'), | ||||||
| enabled: false, | ||||||
| obscureText: true, | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -56,4 +56,15 @@ void main() { | |||||
| await tester.pumpAndSettle(); | ||||||
| expect(findHeadingLevelOnes, findsOne); | ||||||
| }); | ||||||
|
|
||||||
| testWidgets('password fields expose their input purpose', (WidgetTester tester) async { | ||||||
| await pumpsUseCase(tester, TextFieldPasswordUseCase()); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To ensure the widget tree is fully built and settled before querying widgets or semantics, it is recommended to call
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test only reads EditableText.autofillHints, which is set once pumpWidget builds the tree, so there's nothing to settle. The other tests in this file query right after pumpsUseCase too. The email test settles because it checks semantics. |
||||||
|
|
||||||
| for (final key in <Key>[const Key('enabled password'), const Key('disabled password')]) { | ||||||
| final EditableText editableText = tester.widget<EditableText>( | ||||||
| find.descendant(of: find.byKey(key), matching: find.byType(EditableText)), | ||||||
| ); | ||||||
| expect(editableText.autofillHints, contains(AutofillHints.password)); | ||||||
| } | ||||||
| }); | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the Dart style guide, type arguments on collection literals should be omitted when they can be inferred from the context. Since
autofillHintsexpects anIterable<String>?, the<String>type argument is redundant.References
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping the explicit to match the surrounding code, which uses explicit collection types throughout ([...]), and existing material_ui usage such as autofillHints: const [...] in text_form_field_test.dart.