@@ -6586,7 +6586,39 @@ void main() {
65866586 expect (tester.getBottomLeft (find.byKey (keyB)).dy, rowBottomY);
65876587 });
65886588
6589- testWidgets ('TextField semantics include label when unfocused and label/hint when focused' , (WidgetTester tester) async {
6589+ testWidgets ('TextField semantics include label when unfocused and label/hint when focused if input is empty' , (WidgetTester tester) async {
6590+ final SemanticsTester semantics = SemanticsTester (tester);
6591+ final TextEditingController controller = TextEditingController (text: '' );
6592+ final Key key = UniqueKey ();
6593+
6594+ await tester.pumpWidget (
6595+ overlay (
6596+ child: TextField (
6597+ key: key,
6598+ controller: controller,
6599+ decoration: const InputDecoration (
6600+ hintText: 'hint' ,
6601+ labelText: 'label' ,
6602+ ),
6603+ ),
6604+ ),
6605+ );
6606+
6607+ final SemanticsNode node = tester.getSemantics (find.byKey (key));
6608+
6609+ expect (node.label, 'label' );
6610+ expect (node.value, '' );
6611+
6612+ // Focus text field.
6613+ await tester.tap (find.byKey (key));
6614+ await tester.pump ();
6615+
6616+ expect (node.label, 'label\n hint' );
6617+ expect (node.value, '' );
6618+ semantics.dispose ();
6619+ });
6620+
6621+ testWidgets ('TextField semantics alway include label and not hint when input value is not empty' , (WidgetTester tester) async {
65906622 final SemanticsTester semantics = SemanticsTester (tester);
65916623 final TextEditingController controller = TextEditingController (text: 'value' );
65926624 final Key key = UniqueKey ();
@@ -6613,7 +6645,7 @@ void main() {
66136645 await tester.tap (find.byKey (key));
66146646 await tester.pump ();
66156647
6616- expect (node.label, 'label\n hint ' );
6648+ expect (node.label, 'label' );
66176649 expect (node.value, 'value' );
66186650 semantics.dispose ();
66196651 });
0 commit comments