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
d75cfa58
Unverified
Commit
d75cfa58
authored
Feb 23, 2021
by
chunhtai
Committed by
GitHub
Feb 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hide selection handles from semantics (#76641)
* Hide selection handles from semantics * update comment
parent
1794e81f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
14 deletions
+64
-14
text_selection.dart
packages/flutter/lib/src/widgets/text_selection.dart
+23
-14
text_field_test.dart
packages/flutter/test/material/text_field_test.dart
+41
-0
No files found.
packages/flutter/lib/src/widgets/text_selection.dart
View file @
d75cfa58
...
...
@@ -547,13 +547,17 @@ class TextSelectionOverlay {
}
Widget
_buildHandle
(
BuildContext
context
,
_TextSelectionHandlePosition
position
)
{
Widget
handle
;
if
((
_selection
.
isCollapsed
&&
position
==
_TextSelectionHandlePosition
.
end
)
||
selectionControls
==
null
)
return
Container
();
// hide the second handle when collapsed
return
Visibility
(
handle
=
Container
();
// hide the second handle when collapsed
else
{
handle
=
Visibility
(
visible:
handlesVisible
,
child:
_TextSelectionHandleOverlay
(
onSelectionHandleChanged:
(
TextSelection
newSelection
)
{
_handleSelectionHandleChanged
(
newSelection
,
position
);
},
onSelectionHandleChanged:
(
TextSelection
newSelection
)
{
_handleSelectionHandleChanged
(
newSelection
,
position
);
},
onSelectionHandleTapped:
onSelectionHandleTapped
,
startHandleLayerLink:
startHandleLayerLink
,
endHandleLayerLink:
endHandleLayerLink
,
...
...
@@ -562,7 +566,12 @@ class TextSelectionOverlay {
selectionControls:
selectionControls
,
position:
position
,
dragStartBehavior:
dragStartBehavior
,
));
)
);
}
return
ExcludeSemantics
(
child:
handle
,
);
}
Widget
_buildToolbar
(
BuildContext
context
)
{
...
...
packages/flutter/test/material/text_field_test.dart
View file @
d75cfa58
...
...
@@ -1119,6 +1119,47 @@ void main() {
expect
(
fadeFinder
,
findsNothing
);
});
testWidgets
(
'selection handles are excluded from the semantics'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
final
TextEditingController
controller
=
TextEditingController
();
await
tester
.
pumpWidget
(
overlay
(
child:
TextField
(
controller:
controller
,
),
),
);
const
String
testValue
=
'abcdefghi'
;
await
tester
.
enterText
(
find
.
byType
(
TextField
),
testValue
);
expect
(
controller
.
value
.
text
,
testValue
);
await
skipPastScrollingAnimation
(
tester
);
// Tap on the text field to show the handle.
await
tester
.
tap
(
find
.
byType
(
TextField
));
await
tester
.
pumpAndSettle
();
// The semantics should only have the text field.
expect
(
semantics
,
hasSemantics
(
TestSemantics
.
root
(
children:
<
TestSemantics
>[
TestSemantics
(
id:
1
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isTextField
,
SemanticsFlag
.
isFocused
],
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
,
SemanticsAction
.
moveCursorBackwardByCharacter
,
SemanticsAction
.
setSelection
,
SemanticsAction
.
paste
,
SemanticsAction
.
moveCursorBackwardByWord
],
value:
'abcdefghi'
,
textDirection:
TextDirection
.
ltr
,
textSelection:
const
TextSelection
.
collapsed
(
offset:
9
),
),
],
),
ignoreRect:
true
,
ignoreTransform:
true
,
));
semantics
.
dispose
();
});
testWidgets
(
'Mouse long press is just like a tap'
,
(
WidgetTester
tester
)
async
{
final
TextEditingController
controller
=
TextEditingController
();
...
...
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