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
6a4808b4
Unverified
Commit
6a4808b4
authored
Jan 15, 2021
by
chunhtai
Committed by
GitHub
Jan 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused semantics tap action for readonly textfield and selectable text (#74066)
parent
1b310472
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
20 deletions
+45
-20
text_field.dart
packages/flutter/lib/src/cupertino/text_field.dart
+1
-1
selectable_text.dart
packages/flutter/lib/src/material/selectable_text.dart
+0
-5
text_field.dart
packages/flutter/lib/src/material/text_field.dart
+1
-1
text_field_test.dart
packages/flutter/test/cupertino/text_field_test.dart
+20
-0
text_field_test.dart
packages/flutter/test/material/text_field_test.dart
+21
-0
selectable_text_test.dart
packages/flutter/test/widgets/selectable_text_test.dart
+2
-13
No files found.
packages/flutter/lib/src/cupertino/text_field.dart
View file @
6a4808b4
...
...
@@ -1186,7 +1186,7 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio
return
Semantics
(
enabled:
enabled
,
onTap:
!
enabled
?
null
:
()
{
onTap:
!
enabled
||
widget
.
readOnly
?
null
:
()
{
if
(!
controller
.
selection
.
isValid
)
{
controller
.
selection
=
TextSelection
.
collapsed
(
offset:
controller
.
text
.
length
);
}
...
...
packages/flutter/lib/src/material/selectable_text.dart
View file @
6a4808b4
...
...
@@ -652,11 +652,6 @@ class _SelectableTextState extends State<SelectableText> with AutomaticKeepAlive
);
return
Semantics
(
onTap:
()
{
if
(!
_controller
.
selection
.
isValid
)
_controller
.
selection
=
TextSelection
.
collapsed
(
offset:
_controller
.
text
.
length
);
_effectiveFocusNode
.
requestFocus
();
},
onLongPress:
()
{
_effectiveFocusNode
.
requestFocus
();
},
...
...
packages/flutter/lib/src/material/text_field.dart
View file @
6a4808b4
...
...
@@ -1282,7 +1282,7 @@ class _TextFieldState extends State<TextField> with RestorationMixin implements
return
Semantics
(
maxValueLength:
semanticsMaxValueLength
,
currentValueLength:
_currentLength
,
onTap:
()
{
onTap:
widget
.
readOnly
?
null
:
()
{
if
(!
_effectiveController
.
selection
.
isValid
)
_effectiveController
.
selection
=
TextSelection
.
collapsed
(
offset:
_effectiveController
.
text
.
length
);
_requestKeyboard
();
...
...
packages/flutter/test/cupertino/text_field_test.dart
View file @
6a4808b4
...
...
@@ -13,6 +13,7 @@ import 'package:flutter/gestures.dart' show DragStartBehavior, PointerDeviceKind
import
'package:flutter_test/flutter_test.dart'
;
import
'../rendering/mock_canvas.dart'
;
import
'../widgets/semantics_tester.dart'
;
class
MockClipboard
{
Object
_clipboardData
=
<
String
,
dynamic
>{
...
...
@@ -1589,6 +1590,25 @@ void main() {
},
);
testWidgets
(
'Readonly text field does not have tap action'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
await
tester
.
pumpWidget
(
const
CupertinoApp
(
home:
Center
(
child:
CupertinoTextField
(
maxLength:
10
,
readOnly:
true
,
),
),
),
);
expect
(
semantics
,
isNot
(
includesNodeWith
(
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
])));
semantics
.
dispose
();
});
testWidgets
(
'double tap selects word and first tap of double tap moves cursor'
,
(
WidgetTester
tester
)
async
{
...
...
packages/flutter/test/material/text_field_test.dart
View file @
6a4808b4
...
...
@@ -3944,6 +3944,27 @@ void main() {
semantics
.
dispose
();
});
testWidgets
(
'Readonly text field does not have tap action'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
Material
(
child:
Center
(
child:
TextField
(
maxLength:
10
,
readOnly:
true
,
),
),
),
),
);
expect
(
semantics
,
isNot
(
includesNodeWith
(
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
])));
semantics
.
dispose
();
});
testWidgets
(
'Disabled text field hides helper and counter'
,
(
WidgetTester
tester
)
async
{
const
String
helperText
=
'helper text'
;
const
String
counterText
=
'counter text'
;
...
...
packages/flutter/test/widgets/selectable_text_test.dart
View file @
6a4808b4
...
...
@@ -1937,7 +1937,6 @@ void main() {
textDirection:
TextDirection
.
ltr
,
value:
'Guten Tag'
,
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
,
SemanticsAction
.
longPress
,
],
flags:
<
SemanticsFlag
>[
...
...
@@ -1963,7 +1962,6 @@ void main() {
value:
'Guten Tag'
,
textSelection:
const
TextSelection
.
collapsed
(
offset:
9
),
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
,
SemanticsAction
.
longPress
,
SemanticsAction
.
moveCursorBackwardByCharacter
,
SemanticsAction
.
moveCursorBackwardByWord
,
...
...
@@ -1990,7 +1988,6 @@ void main() {
textSelection:
const
TextSelection
.
collapsed
(
offset:
4
),
value:
'Guten Tag'
,
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
,
SemanticsAction
.
longPress
,
SemanticsAction
.
moveCursorBackwardByCharacter
,
SemanticsAction
.
moveCursorForwardByCharacter
,
...
...
@@ -2019,7 +2016,6 @@ void main() {
textSelection:
const
TextSelection
.
collapsed
(
offset:
0
),
value:
'Guten Tag'
,
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
,
SemanticsAction
.
longPress
,
SemanticsAction
.
moveCursorForwardByCharacter
,
SemanticsAction
.
moveCursorForwardByWord
,
...
...
@@ -2062,7 +2058,6 @@ void main() {
value:
'Guten Tag'
,
textDirection:
TextDirection
.
ltr
,
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
,
SemanticsAction
.
longPress
,
// Absent the following because enableInteractiveSelection: false
// SemanticsAction.moveCursorBackwardByCharacter,
...
...
@@ -2108,7 +2103,6 @@ void main() {
value:
'Hello'
,
textDirection:
TextDirection
.
ltr
,
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
,
SemanticsAction
.
longPress
,
],
flags:
<
SemanticsFlag
>[
...
...
@@ -2135,7 +2129,6 @@ void main() {
textSelection:
const
TextSelection
.
collapsed
(
offset:
5
),
textDirection:
TextDirection
.
ltr
,
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
,
SemanticsAction
.
longPress
,
SemanticsAction
.
moveCursorBackwardByCharacter
,
SemanticsAction
.
moveCursorBackwardByWord
,
...
...
@@ -2162,7 +2155,6 @@ void main() {
textSelection:
const
TextSelection
(
baseOffset:
5
,
extentOffset:
3
),
textDirection:
TextDirection
.
ltr
,
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
,
SemanticsAction
.
longPress
,
SemanticsAction
.
moveCursorBackwardByCharacter
,
SemanticsAction
.
moveCursorForwardByCharacter
,
...
...
@@ -2218,7 +2210,6 @@ void main() {
textSelection:
const
TextSelection
.
collapsed
(
offset:
5
),
textDirection:
TextDirection
.
ltr
,
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
,
SemanticsAction
.
longPress
,
SemanticsAction
.
moveCursorBackwardByCharacter
,
SemanticsAction
.
moveCursorBackwardByWord
,
...
...
@@ -2265,7 +2256,6 @@ void main() {
textSelection:
const
TextSelection
(
baseOffset:
0
,
extentOffset:
5
),
textDirection:
TextDirection
.
ltr
,
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
,
SemanticsAction
.
longPress
,
SemanticsAction
.
moveCursorBackwardByCharacter
,
SemanticsAction
.
moveCursorBackwardByWord
,
...
...
@@ -2315,7 +2305,7 @@ void main() {
SemanticsFlag
.
isTextField
,
SemanticsFlag
.
isMultiline
,
],
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
,
SemanticsAction
.
longPress
],
actions:
<
SemanticsAction
>[
SemanticsAction
.
longPress
],
value:
testValue
,
textDirection:
TextDirection
.
ltr
,
),
...
...
@@ -2324,7 +2314,7 @@ void main() {
ignoreRect:
true
,
ignoreTransform:
true
,
));
semanticsOwner
.
performAction
(
inputFieldId
,
SemanticsAction
.
tap
);
semanticsOwner
.
performAction
(
inputFieldId
,
SemanticsAction
.
longPress
);
await
tester
.
pump
();
expect
(
semantics
,
hasSemantics
(
...
...
@@ -2339,7 +2329,6 @@ void main() {
SemanticsFlag
.
isFocused
,
],
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
,
SemanticsAction
.
longPress
,
SemanticsAction
.
moveCursorBackwardByCharacter
,
SemanticsAction
.
moveCursorBackwardByWord
,
...
...
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