Skip to content

Commit 0675f4b

Browse files
committed
[material_ui] Drop the email suffix from a11y_assessments text fields
1 parent 0d8249d commit 0675f4b

2 files changed

Lines changed: 32 additions & 41 deletions

File tree

‎packages/material_ui/test_apps/a11y_assessments/lib/use_cases/text_field.dart‎

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -33,39 +33,31 @@ class _MainWidget extends StatelessWidget {
3333
appBar: AppBar(title: Semantics(headingLevel: 1, child: Text('$pageTitle Demo'))),
3434
body: ListView(
3535
children: <Widget>[
36-
Semantics(
37-
label: 'Input field with suffix @gmail.com',
38-
child: const TextField(
39-
key: Key('enabled text field'),
40-
keyboardType: TextInputType.emailAddress,
41-
autofillHints: <String>[AutofillHints.email],
42-
decoration: InputDecoration(
43-
labelText: 'Email',
44-
suffixText: '@gmail.com',
45-
hintText: 'Enter your email',
46-
// The field is single-line, so let the hint wrap at large
47-
// text scales, one line per word.
48-
hintMaxLines: 3,
49-
),
36+
const TextField(
37+
key: Key('enabled text field'),
38+
keyboardType: TextInputType.emailAddress,
39+
autofillHints: <String>[AutofillHints.email],
40+
decoration: InputDecoration(
41+
labelText: 'Email',
42+
hintText: 'Enter your email',
43+
// The field is single-line, so let the hint wrap at large
44+
// text scales, one line per word.
45+
hintMaxLines: 3,
5046
),
5147
),
52-
Semantics(
53-
label: 'Input field with suffix @gmail.com',
54-
child: TextField(
55-
key: const Key('disabled text field'),
56-
keyboardType: TextInputType.emailAddress,
57-
autofillHints: const <String>[AutofillHints.email],
58-
decoration: const InputDecoration(
59-
labelText: 'Email',
60-
suffixText: '@gmail.com',
61-
hintText: 'Enter your email',
62-
// The field is single-line, so let the hint wrap at large
63-
// text scales, one line per word.
64-
hintMaxLines: 3,
65-
),
66-
enabled: false,
67-
controller: TextEditingController(text: 'xyz'),
48+
TextField(
49+
key: const Key('disabled text field'),
50+
keyboardType: TextInputType.emailAddress,
51+
autofillHints: const <String>[AutofillHints.email],
52+
decoration: const InputDecoration(
53+
labelText: 'Email',
54+
hintText: 'Enter your email',
55+
// The field is single-line, so let the hint wrap at large
56+
// text scales, one line per word.
57+
hintMaxLines: 3,
6858
),
59+
enabled: false,
60+
controller: TextEditingController(text: 'xyz'),
6961
),
7062
],
7163
),

‎packages/material_ui/test_apps/a11y_assessments/test/text_field_test.dart‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import 'dart:ui' show SemanticsInputType;
66

77
import 'package:a11y_assessments/use_cases/text_field.dart';
8+
import 'package:flutter/rendering.dart' show RenderParagraph;
89
import 'package:flutter_test/flutter_test.dart';
910
import 'package:material_ui/material_ui.dart';
1011

@@ -34,6 +35,11 @@ void main() {
3435
});
3536

3637
testWidgets('font size increase does not ellipsize hint text', (WidgetTester tester) async {
38+
// A narrow view forces the hint to wrap at 3x text scale.
39+
tester.view.physicalSize = const Size(320, 640);
40+
tester.view.devicePixelRatio = 1.0;
41+
addTearDown(tester.view.reset);
42+
3743
await pumpsUseCase(tester, TextFieldUseCase());
3844
await tester.pumpWidget(
3945
MaterialApp(
@@ -53,20 +59,13 @@ void main() {
5359
final Finder finder = find.byKey(const Key('enabled text field'));
5460
await tester.tap(finder);
5561
await tester.pumpAndSettle();
56-
final Size size = tester.getSize(finder);
57-
// Should have a multi-line height.
58-
expect(size.height, 280);
62+
final RenderParagraph hint = tester.renderObject<RenderParagraph>(
63+
find.descendant(of: finder, matching: find.text('Enter your email')),
64+
);
65+
expect(hint.didExceedMaxLines, isFalse);
5966
}
6067
});
6168

62-
testWidgets('text field wrapper exists', (WidgetTester tester) async {
63-
await pumpsUseCase(tester, TextFieldUseCase());
64-
const textFieldLabel = 'Input field with suffix @gmail.com';
65-
66-
final Finder semanticsWidgets = find.bySemanticsLabel(RegExp(textFieldLabel));
67-
expect(semanticsWidgets, findsExactly(2));
68-
});
69-
7069
testWidgets('text field demo page has one h1 tag', (WidgetTester tester) async {
7170
await pumpsUseCase(tester, TextFieldUseCase());
7271
final Finder findHeadingLevelOnes = find.bySemanticsLabel('TextField Demo');

0 commit comments

Comments
 (0)