Unverified Commit 91f8d3da authored by rami-a's avatar rami-a Committed by GitHub

Prevent disabled cupertino textfield from being edited with voiceover/talkback (#48902)

parent 4c1d79f4
......@@ -929,7 +929,8 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with AutomaticK
);
return Semantics(
onTap: () {
enabled: enabled,
onTap: !enabled ? null : () {
if (!controller.selection.isValid) {
controller.selection = TextSelection.collapsed(offset: controller.text.length);
}
......
......@@ -3944,4 +3944,61 @@ void main() {
await tester.pump();
expect(focusNode3.hasPrimaryFocus, isTrue);
});
testWidgets('Cupertino text field semantics', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: Center(
child: ConstrainedBox(
constraints: BoxConstraints.loose(const Size(200, 200)),
child: const CupertinoTextField(),
),
),
),
);
expect(
tester.getSemantics(
find.descendant(
of: find.byType(CupertinoTextField),
matching: find.byType(Semantics),
).first,
),
matchesSemantics(
isTextField: true,
isEnabled: true,
hasEnabledState: true,
hasTapAction: true,
),
);
});
testWidgets('Disabled Cupertino text field semantics', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: Center(
child: ConstrainedBox(
constraints: BoxConstraints.loose(const Size(200, 200)),
child: const CupertinoTextField(
enabled: false,
),
),
),
),
);
expect(
tester.getSemantics(
find.descendant(
of: find.byType(CupertinoTextField),
matching: find.byType(Semantics),
).first,
),
matchesSemantics(
isEnabled: false,
hasEnabledState: true,
hasTapAction: false,
),
);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment