fix empty selection arrow when double clicked on empty read only textfield in ios (#34068)

This commit is contained in:
chunhtai 2019-06-10 09:19:41 -07:00 committed by GitHub
parent 991da4f77f
commit 38a5bbb44e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 58 additions and 0 deletions

View File

@ -115,6 +115,10 @@ class _TextSelectionToolbar extends StatelessWidget {
items.add(onePhysicalPixelVerticalDivider); items.add(onePhysicalPixelVerticalDivider);
items.add(_buildToolbarButton(localizations.selectAllButtonLabel, handleSelectAll)); items.add(_buildToolbarButton(localizations.selectAllButtonLabel, handleSelectAll));
} }
// If there is no option available, build an empty widget.
if (items.isEmpty) {
return Container(width: 0.0, height: 0.0);
}
const Widget padding = Padding(padding: EdgeInsets.only(bottom: 10.0)); const Widget padding = Padding(padding: EdgeInsets.only(bottom: 10.0));

View File

@ -49,6 +49,11 @@ class _TextSelectionToolbar extends StatelessWidget {
if (handleSelectAll != null) if (handleSelectAll != null)
items.add(FlatButton(child: Text(localizations.selectAllButtonLabel), onPressed: handleSelectAll)); items.add(FlatButton(child: Text(localizations.selectAllButtonLabel), onPressed: handleSelectAll));
// If there is no option available, build an empty widget.
if (items.isEmpty) {
return Container(width: 0.0, height: 0.0);
}
return Material( return Material(
elevation: 1.0, elevation: 1.0,
child: Container( child: Container(

View File

@ -854,6 +854,55 @@ void main() {
expect(find.text('CUT'), findsNothing); expect(find.text('CUT'), findsNothing);
}); });
testWidgets('text field build empty tool bar when no options available ios', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS),
home: const Material(
child: TextField(
readOnly: true,
),
),
)
);
await tester.tap(find.byType(TextField));
await tester.pump(const Duration(milliseconds: 50));
await tester.tap(find.byType(TextField));
// Wait for context menu to be built.
await tester.pumpAndSettle();
final RenderBox container = tester.renderObject(find.descendant(
of: find.byType(FadeTransition),
matching: find.byType(Container),
));
expect(container.size, Size.zero);
});
testWidgets('text field build empty tool bar when no options available android', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Material(
child: TextField(
readOnly: true,
),
),
)
);
await tester.tap(find.byType(TextField));
await tester.pump(const Duration(milliseconds: 50));
await tester.tap(find.byType(TextField));
// Wait for context menu to be built.
await tester.pumpAndSettle();
final RenderBox container = tester.renderObject(find.descendant(
of: find.byType(FadeTransition),
matching: find.byType(Container),
));
expect(container.size, Size.zero);
});
testWidgets('Sawping controllers should update selection', (WidgetTester tester) async { testWidgets('Sawping controllers should update selection', (WidgetTester tester) async {
TextEditingController controller = TextEditingController(text: 'readonly'); TextEditingController controller = TextEditingController(text: 'readonly');
final OverlayEntry entry = OverlayEntry( final OverlayEntry entry = OverlayEntry(