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
1ab3cb9e
Unverified
Commit
1ab3cb9e
authored
Mar 08, 2023
by
Callum Moffat
Committed by
GitHub
Mar 08, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clear _scribbleCacheKey when connection closes (#122145)
Clear _scribbleCacheKey when connection closes
parent
00916010
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
0 deletions
+82
-0
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+1
-0
editable_text_test.dart
packages/flutter/test/widgets/editable_text_test.dart
+81
-0
No files found.
packages/flutter/lib/src/widgets/editable_text.dart
View file @
1ab3cb9e
...
...
@@ -3165,6 +3165,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
_textInputConnection
!.
close
();
_textInputConnection
=
null
;
_lastKnownRemoteTextEditingValue
=
null
;
_scribbleCacheKey
=
null
;
removeTextPlaceholder
();
}
}
...
...
packages/flutter/test/widgets/editable_text_test.dart
View file @
1ab3cb9e
...
...
@@ -852,6 +852,87 @@ void main() {
expect
(
focusNode
.
hasFocus
,
isFalse
);
});
testWidgets
(
'selection rects re-sent when refocused'
,
(
WidgetTester
tester
)
async
{
final
List
<
List
<
SelectionRect
>>
log
=
<
List
<
SelectionRect
>>[];
SystemChannels
.
textInput
.
setMockMethodCallHandler
((
MethodCall
methodCall
)
async
{
if
(
methodCall
.
method
==
'TextInput.setSelectionRects'
)
{
final
List
<
dynamic
>
args
=
methodCall
.
arguments
as
List
<
dynamic
>;
final
List
<
SelectionRect
>
selectionRects
=
<
SelectionRect
>[];
for
(
final
dynamic
rect
in
args
)
{
selectionRects
.
add
(
SelectionRect
(
position:
(
rect
as
List
<
dynamic
>)[
4
]
as
int
,
bounds:
Rect
.
fromLTWH
(
rect
[
0
]
as
double
,
rect
[
1
]
as
double
,
rect
[
2
]
as
double
,
rect
[
3
]
as
double
),
));
}
log
.
add
(
selectionRects
);
}
});
final
TextEditingController
controller
=
TextEditingController
();
final
ScrollController
scrollController
=
ScrollController
();
controller
.
text
=
'Text1'
;
Future
<
void
>
pumpEditableText
({
double
?
width
,
double
?
height
,
TextAlign
textAlign
=
TextAlign
.
start
})
async
{
await
tester
.
pumpWidget
(
MediaQuery
(
data:
const
MediaQueryData
(),
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
SizedBox
(
width:
width
,
height:
height
,
child:
EditableText
(
controller:
controller
,
textAlign:
textAlign
,
scrollController:
scrollController
,
maxLines:
null
,
focusNode:
focusNode
,
cursorWidth:
0
,
style:
Typography
.
material2018
().
black
.
titleMedium
!,
cursorColor:
Colors
.
blue
,
backgroundCursorColor:
Colors
.
grey
,
),
),
),
),
),
);
}
const
List
<
SelectionRect
>
expectedRects
=
<
SelectionRect
>[
SelectionRect
(
position:
0
,
bounds:
Rect
.
fromLTRB
(
0.0
,
0.0
,
14.0
,
14.0
)),
SelectionRect
(
position:
1
,
bounds:
Rect
.
fromLTRB
(
14.0
,
0.0
,
28.0
,
14.0
)),
SelectionRect
(
position:
2
,
bounds:
Rect
.
fromLTRB
(
28.0
,
0.0
,
42.0
,
14.0
)),
SelectionRect
(
position:
3
,
bounds:
Rect
.
fromLTRB
(
42.0
,
0.0
,
56.0
,
14.0
)),
SelectionRect
(
position:
4
,
bounds:
Rect
.
fromLTRB
(
56.0
,
0.0
,
70.0
,
14.0
))
];
await
pumpEditableText
();
expect
(
log
,
isEmpty
);
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
// First update.
expect
(
log
.
single
,
expectedRects
);
log
.
clear
();
await
tester
.
pumpAndSettle
();
expect
(
log
,
isEmpty
);
focusNode
.
unfocus
();
await
tester
.
pumpAndSettle
();
expect
(
log
,
isEmpty
);
focusNode
.
requestFocus
();
//await tester.showKeyboard(find.byType(EditableText));
await
tester
.
pumpAndSettle
();
// Should re-receive the same rects.
expect
(
log
.
single
,
expectedRects
);
log
.
clear
();
// On web, we should rely on the browser's implementation of Scribble, so we will not send selection rects.
},
skip:
kIsWeb
,
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
iOS
}));
// [intended]
testWidgets
(
'EditableText does not derive selection color from DefaultSelectionStyle'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/103341.
const
TextEditingValue
value
=
TextEditingValue
(
...
...
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