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
6280b391
Unverified
Commit
6280b391
authored
Mar 31, 2020
by
Gary Qian
Committed by
GitHub
Mar 31, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Un-gate value setting in formatter repeat check logic (#53613)
parent
cb4147cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
5 deletions
+48
-5
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+5
-5
editable_text_test.dart
packages/flutter/test/widgets/editable_text_test.dart
+43
-0
No files found.
packages/flutter/lib/src/widgets/editable_text.dart
View file @
6280b391
...
...
@@ -1676,13 +1676,13 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
value
=
_whitespaceFormatter
.
formatEditUpdate
(
_value
,
value
);
_lastFormattedValue
=
value
;
}
// If the text, selection, or composing region has changed, we should update the
// locally stored TextEditingValue to the new one.
if
(!
isRepeatText
||
!
isRepeatSelection
||
!
isRepeatComposing
)
{
_value
=
value
;
}
else
if
(
textChanged
&&
_lastFormattedValue
!=
null
)
{
_value
=
value
;
// Use the last formatted value when an identical repeat pass is detected.
if
(
isRepeatText
&&
isRepeatSelection
&&
isRepeatComposing
&&
textChanged
&&
_lastFormattedValue
!=
null
)
{
_value
=
_lastFormattedValue
;
}
// Always attempt to send the value. If the value has changed, then it will send,
// otherwise, it will short-circuit.
_updateRemoteEditingValueIfNeeded
();
...
...
packages/flutter/test/widgets/editable_text_test.dart
View file @
6280b391
...
...
@@ -4313,6 +4313,49 @@ void main() {
expect
(
formatter
.
log
,
referenceLog
);
});
// Regression test for https://github.com/flutter/flutter/issues/53612
testWidgets
(
'formatter logic handles initial repeat edge case'
,
(
WidgetTester
tester
)
async
{
final
MockTextFormatter
formatter
=
MockTextFormatter
();
await
tester
.
pumpWidget
(
MediaQuery
(
data:
const
MediaQueryData
(
devicePixelRatio:
1.0
),
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
FocusScope
(
node:
focusScopeNode
,
autofocus:
true
,
child:
EditableText
(
backgroundCursorColor:
Colors
.
grey
,
controller:
controller
,
focusNode:
focusNode
,
maxLines:
1
,
// Sets text keyboard implicitly.
style:
textStyle
,
cursorColor:
cursorColor
,
inputFormatters:
<
TextInputFormatter
>[
formatter
],
),
),
),
),
);
await
tester
.
tap
(
find
.
byType
(
EditableText
));
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
controller
.
text
=
''
;
await
tester
.
idle
();
final
EditableTextState
state
=
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
''
));
expect
(
state
.
wantKeepAlive
,
true
);
expect
(
formatter
.
formatCallCount
,
0
);
state
.
updateEditingValue
(
const
TextEditingValue
(
text:
''
));
state
.
updateEditingValue
(
const
TextEditingValue
(
text:
''
,
composing:
TextRange
(
start:
1
,
end:
2
)));
state
.
updateEditingValue
(
const
TextEditingValue
(
text:
'0'
));
// pass to formatter once to check the values.
expect
(
formatter
.
lastOldValue
.
composing
,
const
TextRange
(
start:
1
,
end:
2
));
expect
(
formatter
.
lastOldValue
.
text
,
''
);
});
testWidgets
(
'Whitespace directionality formatter input Arabic'
,
(
WidgetTester
tester
)
async
{
final
TextEditingController
controller
=
TextEditingController
(
text:
'testText'
);
await
tester
.
pumpWidget
(
...
...
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