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
4ff7fc64
Unverified
Commit
4ff7fc64
authored
Nov 17, 2022
by
chunhtai
Committed by
GitHub
Nov 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes a bug where dragging a collapsed handle in TextField does not vibrate (#115586)
parent
a5a368cb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
2 deletions
+56
-2
text_selection.dart
packages/flutter/lib/src/widgets/text_selection.dart
+1
-2
text_field_test.dart
packages/flutter/test/material/text_field_test.dart
+55
-0
No files found.
packages/flutter/lib/src/widgets/text_selection.dart
View file @
4ff7fc64
...
...
@@ -1163,8 +1163,7 @@ class SelectionOverlay {
set
selectionEndpoints
(
List
<
TextSelectionPoint
>
value
)
{
if
(!
listEquals
(
_selectionEndpoints
,
value
))
{
markNeedsBuild
();
if
((
_isDraggingEndHandle
||
_isDraggingStartHandle
)
&&
_startHandleType
!=
TextSelectionHandleType
.
collapsed
)
{
if
(
_isDraggingEndHandle
||
_isDraggingStartHandle
)
{
switch
(
defaultTargetPlatform
)
{
case
TargetPlatform
.
android
:
HapticFeedback
.
selectionClick
();
...
...
packages/flutter/test/material/text_field_test.dart
View file @
4ff7fc64
...
...
@@ -2532,6 +2532,61 @@ void main() {
expect
(
feedback
.
hapticCount
,
2
);
});
testWidgets
(
'Draging a collapsed handle should trigger feedback.'
,
(
WidgetTester
tester
)
async
{
final
FeedbackTester
feedback
=
FeedbackTester
();
addTearDown
(
feedback
.
dispose
);
final
TextEditingController
controller
=
TextEditingController
();
await
tester
.
pumpWidget
(
overlay
(
child:
TextField
(
dragStartBehavior:
DragStartBehavior
.
down
,
controller:
controller
,
),
),
);
const
String
testValue
=
'abc def ghi'
;
await
tester
.
enterText
(
find
.
byType
(
TextField
),
testValue
);
expect
(
feedback
.
hapticCount
,
0
);
await
skipPastScrollingAnimation
(
tester
);
// Tap the 'e' to bring up a collapsed handle.
final
Offset
ePos
=
textOffsetToPosition
(
tester
,
testValue
.
indexOf
(
'e'
));
TestGesture
gesture
=
await
tester
.
startGesture
(
ePos
,
pointer:
7
);
await
tester
.
pump
();
await
gesture
.
up
();
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
milliseconds:
200
));
// skip past the frame where the opacity is zero
final
TextSelection
selection
=
controller
.
selection
;
expect
(
selection
.
baseOffset
,
5
);
expect
(
selection
.
extentOffset
,
5
);
expect
(
feedback
.
hapticCount
,
0
);
final
RenderEditable
renderEditable
=
findRenderEditable
(
tester
);
final
List
<
TextSelectionPoint
>
endpoints
=
globalize
(
renderEditable
.
getEndpointsForSelection
(
selection
),
renderEditable
,
);
expect
(
endpoints
.
length
,
1
);
// Drag the right handle 3 letters to the right.
// Use a small offset because the endpoint is on the very corner
// of the handle.
final
Offset
handlePos
=
endpoints
[
0
].
point
+
const
Offset
(
1.0
,
1.0
);
final
Offset
newHandlePos
=
textOffsetToPosition
(
tester
,
testValue
.
indexOf
(
'g'
));
gesture
=
await
tester
.
startGesture
(
handlePos
,
pointer:
7
);
await
tester
.
pump
();
await
gesture
.
moveTo
(
newHandlePos
);
await
tester
.
pump
();
await
gesture
.
up
();
await
tester
.
pump
();
expect
(
controller
.
selection
.
baseOffset
,
8
);
expect
(
controller
.
selection
.
extentOffset
,
8
);
expect
(
feedback
.
hapticCount
,
1
);
});
testWidgets
(
'Cannot drag one handle past the other'
,
(
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