mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[CP-stable] Revert "fixed keyboardDismissBehavior on scroll without a drag" (#161329)
This commit is contained in:
parent
17025dd882
commit
bfb4a722bf
@ -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;
|
||||
|
||||
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user