Skip to content

Commit bfb4a72

Browse files
authored
[CP-stable] Revert "fixed keyboardDismissBehavior on scroll without a drag" (#161329)
1 parent 17025dd commit bfb4a72

File tree

2 files changed

+3
-46
lines changed

2 files changed

+3
-46
lines changed

packages/flutter/lib/src/widgets/single_child_scroll_view.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,9 @@ class SingleChildScrollView extends StatelessWidget {
276276
child: scrollable,
277277
onNotification: (ScrollUpdateNotification notification) {
278278
final FocusScopeNode currentScope = FocusScope.of(context);
279-
if (!currentScope.hasPrimaryFocus && currentScope.hasFocus) {
279+
if (notification.dragDetails != null &&
280+
!currentScope.hasPrimaryFocus &&
281+
currentScope.hasFocus) {
280282
FocusManager.instance.primaryFocus?.unfocus();
281283
}
282284
return false;

packages/flutter/test/widgets/single_child_scroll_view_test.dart

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import 'dart:ui';
6-
75
import 'package:flutter/material.dart';
86
import 'package:flutter/rendering.dart';
97
import 'package:flutter_test/flutter_test.dart';
@@ -1120,47 +1118,4 @@ void main() {
11201118

11211119
expect(tester.testTextInput.isVisible, isFalse);
11221120
});
1123-
1124-
testWidgets('keyboardDismissBehavior on scroll without a drag test', (WidgetTester tester) async {
1125-
await tester.pumpWidget(MaterialApp(
1126-
home: Scaffold(
1127-
body: SizedBox(
1128-
height: 1000,
1129-
child: SingleChildScrollView(
1130-
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
1131-
child: Column(
1132-
children: <Widget>[
1133-
Autocomplete<String>(
1134-
optionsBuilder: (TextEditingValue textEditingValue) {
1135-
return<String>['aardvark', 'bobcat', 'chameleon']
1136-
.where((String option) {
1137-
return option.contains(textEditingValue.text.toLowerCase());
1138-
});
1139-
},
1140-
),
1141-
const SizedBox(height: 2000),
1142-
],
1143-
),
1144-
),
1145-
),
1146-
),
1147-
));
1148-
1149-
await tester.tap(find.byType(Autocomplete<String>));
1150-
await tester.pump();
1151-
1152-
await tester.enterText(find.byType(RawAutocomplete<String>),'aard');
1153-
await tester.pump();
1154-
1155-
expect(find.text('aardvark'), findsOneWidget);
1156-
1157-
final TestPointer testPointer = TestPointer(1, PointerDeviceKind.mouse);
1158-
final Offset scrollStart = tester.getCenter(find.byType(SingleChildScrollView));
1159-
1160-
testPointer.hover(scrollStart);
1161-
await tester.sendEventToBinding(testPointer.scroll(Offset(scrollStart.dx, scrollStart.dy - 100)));
1162-
await tester.pumpAndSettle();
1163-
1164-
expect(find.text('aardvark'), findsNothing);
1165-
});
11661121
}

0 commit comments

Comments
 (0)