Unverified Commit f268f820 authored by LongCatIsLooong's avatar LongCatIsLooong Committed by GitHub

Fix autofill eligibility check (#95210)

parent 5b6de035
......@@ -2191,7 +2191,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
bool get _hasInputConnection => _textInputConnection?.attached ?? false;
/// Whether to send the autofill information to the autofill service. True by
/// default.
bool get _needsAutofill => widget.autofillHints?.isNotEmpty ?? true;
bool get _needsAutofill => _effectiveAutofillClient.textInputConfiguration.autofillConfiguration.enabled;
void _openInputConnection() {
if (!_shouldCreateInputConnection) {
......
......@@ -6585,6 +6585,7 @@ void main() {
'TextInput.setStyle',
'TextInput.setEditingState',
'TextInput.show',
'TextInput.requestAutofill',
'TextInput.setEditingState',
'TextInput.show',
'TextInput.setCaretRect',
......@@ -6648,6 +6649,7 @@ void main() {
'TextInput.setStyle',
'TextInput.setEditingState',
'TextInput.show',
'TextInput.requestAutofill',
'TextInput.setCaretRect',
];
expect(
......@@ -6690,6 +6692,7 @@ void main() {
'TextInput.setStyle',
'TextInput.setEditingState',
'TextInput.show',
'TextInput.requestAutofill',
'TextInput.setEditingState',
'TextInput.show',
'TextInput.setCaretRect',
......@@ -6740,6 +6743,7 @@ void main() {
'TextInput.setStyle',
'TextInput.setEditingState',
'TextInput.show',
'TextInput.requestAutofill',
'TextInput.setEditingState',
'TextInput.show',
'TextInput.setCaretRect',
......@@ -8974,6 +8978,53 @@ void main() {
await tester.pump();
expect(scrollController.offset.roundToDouble(), 0.0);
});
testWidgets('Autofill enabled by default', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
await tester.pumpWidget(
MaterialApp(
home: EditableText(
autofocus: true,
controller: TextEditingController(text: 'A'),
focusNode: focusNode,
style: textStyle,
cursorColor: Colors.blue,
backgroundCursorColor: Colors.grey,
cursorOpacityAnimates: true,
),
),
);
assert(focusNode.hasFocus);
expect(
tester.testTextInput.log,
contains(matchesMethodCall('TextInput.requestAutofill')),
);
});
testWidgets('Autofill can be disabled', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
await tester.pumpWidget(
MaterialApp(
home: EditableText(
autofocus: true,
controller: TextEditingController(text: 'A'),
focusNode: focusNode,
style: textStyle,
cursorColor: Colors.blue,
backgroundCursorColor: Colors.grey,
cursorOpacityAnimates: true,
autofillHints: null,
),
),
);
assert(focusNode.hasFocus);
expect(
tester.testTextInput.log,
isNot(contains(matchesMethodCall('TextInput.requestAutofill'))),
);
});
}
class UnsettableController extends TextEditingController {
......
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