Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
b730a993
Commit
b730a993
authored
Oct 04, 2019
by
Rody Davis
Committed by
chunhtai
Oct 04, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix CupertinoTextField and TextField ToolbarOptions not changing (#40665)
parent
0e605cc4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
131 additions
and
4 deletions
+131
-4
AUTHORS
AUTHORS
+1
-0
text_field.dart
packages/flutter/lib/src/cupertino/text_field.dart
+2
-2
text_field.dart
packages/flutter/lib/src/material/text_field.dart
+2
-2
text_field_test.dart
packages/flutter/test/cupertino/text_field_test.dart
+43
-0
text_field_test.dart
packages/flutter/test/material/text_field_test.dart
+83
-0
No files found.
AUTHORS
View file @
b730a993
...
...
@@ -42,4 +42,5 @@ Igor Katsuba <katsuba.igor@gmail.com>
Diego Velásquez <diego.velasquez.lopez@gmail.com>
Simon Lightfoot <simon@devangels.london>
Sarbagya Dhaubanjar <mail@sarbagyastha.com.np>
Rody Davis Jr <rody.davis.jr@gmail.com>
Robin Jespersen <info@unitedpartners.de>
packages/flutter/lib/src/cupertino/text_field.dart
View file @
b730a993
...
...
@@ -265,7 +265,7 @@ class CupertinoTextField extends StatefulWidget {
assert
(
prefixMode
!=
null
),
assert
(
suffixMode
!=
null
),
keyboardType
=
keyboardType
??
(
maxLines
==
1
?
TextInputType
.
text
:
TextInputType
.
multiline
),
toolbarOptions
=
toolbarOptions
??
obscureText
?
toolbarOptions
=
toolbarOptions
??
(
obscureText
?
const
ToolbarOptions
(
selectAll:
true
,
paste:
true
,
...
...
@@ -275,7 +275,7 @@ class CupertinoTextField extends StatefulWidget {
cut:
true
,
selectAll:
true
,
paste:
true
,
),
)
)
,
super
(
key:
key
);
/// Controls the text being edited.
...
...
packages/flutter/lib/src/material/text_field.dart
View file @
b730a993
...
...
@@ -346,7 +346,7 @@ class TextField extends StatefulWidget {
),
assert
(
maxLength
==
null
||
maxLength
==
TextField
.
noMaxLength
||
maxLength
>
0
),
keyboardType
=
keyboardType
??
(
maxLines
==
1
?
TextInputType
.
text
:
TextInputType
.
multiline
),
toolbarOptions
=
toolbarOptions
??
obscureText
?
toolbarOptions
=
toolbarOptions
??
(
obscureText
?
const
ToolbarOptions
(
selectAll:
true
,
paste:
true
,
...
...
@@ -356,7 +356,7 @@ class TextField extends StatefulWidget {
cut:
true
,
selectAll:
true
,
paste:
true
,
),
)
)
,
super
(
key:
key
);
/// Controls the text being edited.
...
...
packages/flutter/test/cupertino/text_field_test.dart
View file @
b730a993
...
...
@@ -1290,6 +1290,49 @@ void main() {
expect
(
text
.
style
.
fontWeight
,
FontWeight
.
w400
);
});
testWidgets
(
'text field toolbar options correctly changes options'
,
(
WidgetTester
tester
)
async
{
final
TextEditingController
controller
=
TextEditingController
(
text:
'Atwater Peel Sherbrooke Bonaventure'
,
);
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
Column
(
children:
<
Widget
>[
CupertinoTextField
(
controller:
controller
,
toolbarOptions:
const
ToolbarOptions
(
copy:
true
),
),
],
),
),
);
// Long press to put the cursor after the "w".
const
int
index
=
3
;
await
tester
.
longPressAt
(
textOffsetToPosition
(
tester
,
index
));
await
tester
.
pump
();
expect
(
controller
.
selection
,
const
TextSelection
.
collapsed
(
offset:
index
),
);
// Double tap on the same location to select the word around the cursor.
await
tester
.
tapAt
(
textOffsetToPosition
(
tester
,
index
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
50
));
await
tester
.
tapAt
(
textOffsetToPosition
(
tester
,
index
));
await
tester
.
pump
();
expect
(
controller
.
selection
,
const
TextSelection
(
baseOffset:
0
,
extentOffset:
7
),
);
// Selected text shows 'Copy'.
expect
(
find
.
text
(
'Paste'
),
findsNothing
);
expect
(
find
.
text
(
'Copy'
),
findsOneWidget
);
expect
(
find
.
text
(
'Cut'
),
findsNothing
);
expect
(
find
.
text
(
'Select All'
),
findsNothing
);
});
testWidgets
(
'Read only text field'
,
(
WidgetTester
tester
)
async
{
final
TextEditingController
controller
=
TextEditingController
(
text:
'readonly'
);
...
...
packages/flutter/test/material/text_field_test.dart
View file @
b730a993
...
...
@@ -505,6 +505,89 @@ void main() {
);
},
skip:
isBrowser
);
testWidgets
(
'text field toolbar options correctly changes options (iOS)'
,
(
WidgetTester
tester
)
async
{
final
TextEditingController
controller
=
TextEditingController
(
text:
'Atwater Peel Sherbrooke Bonaventure'
,
);
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
platform:
TargetPlatform
.
iOS
),
home:
Material
(
child:
Center
(
child:
TextField
(
controller:
controller
,
toolbarOptions:
const
ToolbarOptions
(
copy:
true
),
),
),
),
),
);
final
Offset
textfieldStart
=
tester
.
getTopLeft
(
find
.
byType
(
TextField
));
// This tap just puts the cursor somewhere different than where the double
// tap will occur to test that the double tap moves the existing cursor first.
await
tester
.
tapAt
(
textfieldStart
+
const
Offset
(
50.0
,
5.0
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
500
));
await
tester
.
tapAt
(
textfieldStart
+
const
Offset
(
150.0
,
5.0
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
50
));
// First tap moved the cursor.
expect
(
controller
.
selection
,
const
TextSelection
.
collapsed
(
offset:
8
,
affinity:
TextAffinity
.
downstream
),
);
await
tester
.
tapAt
(
textfieldStart
+
const
Offset
(
150.0
,
5.0
));
await
tester
.
pump
();
// Second tap selects the word around the cursor.
expect
(
controller
.
selection
,
const
TextSelection
(
baseOffset:
8
,
extentOffset:
12
),
);
// Selected text shows 'Copy', and not 'Paste', 'Cut', 'Select All'.
expect
(
find
.
text
(
'Paste'
),
findsNothing
);
expect
(
find
.
text
(
'Copy'
),
findsOneWidget
);
expect
(
find
.
text
(
'Cut'
),
findsNothing
);
expect
(
find
.
text
(
'Select All'
),
findsNothing
);
},
skip:
isBrowser
);
testWidgets
(
'text field toolbar options correctly changes options (Android)'
,
(
WidgetTester
tester
)
async
{
final
TextEditingController
controller
=
TextEditingController
(
text:
'Atwater Peel Sherbrooke Bonaventure'
,
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Material
(
child:
Center
(
child:
TextField
(
controller:
controller
,
toolbarOptions:
const
ToolbarOptions
(
copy:
true
),
),
),
),
),
);
final
Offset
textfieldStart
=
tester
.
getTopLeft
(
find
.
byType
(
TextField
));
await
tester
.
tapAt
(
textfieldStart
+
const
Offset
(
150.0
,
5.0
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
50
));
await
tester
.
tapAt
(
textfieldStart
+
const
Offset
(
150.0
,
5.0
));
await
tester
.
pump
();
// Selected text shows 'COPY', and not 'PASTE', 'CUT', 'SELECT ALL'.
expect
(
find
.
text
(
'PASTE'
),
findsNothing
);
expect
(
find
.
text
(
'COPY'
),
findsOneWidget
);
expect
(
find
.
text
(
'CUT'
),
findsNothing
);
expect
(
find
.
text
(
'SELECT ALL'
),
findsNothing
);
},
skip:
isBrowser
);
// TODO(hansmuller): restore these tests after the fix for #24876 has landed.
/*
testWidgets('cursor layout has correct width', (WidgetTester tester) async {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment