[CP-stable] Revert "fixed keyboardDismissBehavior on scroll without a drag" (#161329)

This commit is contained in:
Victor Sanni 2025-01-08 15:47:01 -08:00 committed by GitHub
parent 17025dd882
commit bfb4a722bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 46 deletions

View File

@ -276,7 +276,9 @@ class SingleChildScrollView extends StatelessWidget {
child: scrollable,
onNotification: (ScrollUpdateNotification notification) {
final FocusScopeNode currentScope = FocusScope.of(context);
if (!currentScope.hasPrimaryFocus && currentScope.hasFocus) {
if (notification.dragDetails != null &&
!currentScope.hasPrimaryFocus &&
currentScope.hasFocus) {
FocusManager.instance.primaryFocus?.unfocus();
}
return false;

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
@ -1120,47 +1118,4 @@ void main() {
expect(tester.testTextInput.isVisible, isFalse);
});
testWidgets('keyboardDismissBehavior on scroll without a drag test', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
home: Scaffold(
body: SizedBox(
height: 1000,
child: SingleChildScrollView(
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
child: Column(
children: <Widget>[
Autocomplete<String>(
optionsBuilder: (TextEditingValue textEditingValue) {
return<String>['aardvark', 'bobcat', 'chameleon']
.where((String option) {
return option.contains(textEditingValue.text.toLowerCase());
});
},
),
const SizedBox(height: 2000),
],
),
),
),
),
));
await tester.tap(find.byType(Autocomplete<String>));
await tester.pump();
await tester.enterText(find.byType(RawAutocomplete<String>),'aard');
await tester.pump();
expect(find.text('aardvark'), findsOneWidget);
final TestPointer testPointer = TestPointer(1, PointerDeviceKind.mouse);
final Offset scrollStart = tester.getCenter(find.byType(SingleChildScrollView));
testPointer.hover(scrollStart);
await tester.sendEventToBinding(testPointer.scroll(Offset(scrollStart.dx, scrollStart.dy - 100)));
await tester.pumpAndSettle();
expect(find.text('aardvark'), findsNothing);
});
}