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
5024e1ea
Unverified
Commit
5024e1ea
authored
Sep 17, 2020
by
Mouad Debbar
Committed by
GitHub
Sep 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[web] Inform the engine when read-only flag is flipped (#65499)
parent
8cb09cf4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
2 deletions
+65
-2
text_input.dart
packages/flutter/lib/src/services/text_input.dart
+15
-0
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+9
-2
editable_text_test.dart
packages/flutter/test/widgets/editable_text_test.dart
+38
-0
test_text_input.dart
packages/flutter_test/lib/src/test_text_input.dart
+3
-0
No files found.
packages/flutter/lib/src/services/text_input.dart
View file @
5024e1ea
...
...
@@ -880,6 +880,13 @@ class TextInputConnection {
TextInput
.
_instance
.
_requestAutofill
();
}
/// Requests that the text input control update itself according to the new
/// [TextInputConfiguration].
void
updateConfig
(
TextInputConfiguration
configuration
)
{
assert
(
attached
);
TextInput
.
_instance
.
_updateConfig
(
configuration
);
}
/// Requests that the text input control change its internal state to match the given state.
void
setEditingState
(
TextEditingValue
value
)
{
assert
(
attached
);
...
...
@@ -1211,6 +1218,14 @@ class TextInput {
_scheduleHide
();
}
void
_updateConfig
(
TextInputConfiguration
configuration
)
{
assert
(
configuration
!=
null
);
_channel
.
invokeMethod
<
void
>(
'TextInput.updateConfig'
,
configuration
.
toJson
(),
);
}
void
_setEditingState
(
TextEditingValue
value
)
{
assert
(
value
!=
null
);
_channel
.
invokeMethod
<
void
>(
...
...
packages/flutter/lib/src/widgets/editable_text.dart
View file @
5024e1ea
...
...
@@ -1561,15 +1561,22 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
if
(!
_shouldCreateInputConnection
)
{
_closeInputConnectionIfNeeded
();
}
else
{
if
(
oldWidget
.
readOnly
&&
_hasFocus
)
if
(
oldWidget
.
readOnly
&&
_hasFocus
)
{
_openInputConnection
();
}
}
if
(
kIsWeb
&&
_hasInputConnection
)
{
if
(
oldWidget
.
readOnly
!=
widget
.
readOnly
)
{
_textInputConnection
!.
updateConfig
(
textInputConfiguration
);
}
}
if
(
widget
.
style
!=
oldWidget
.
style
)
{
final
TextStyle
style
=
widget
.
style
;
// The _textInputConnection will pick up the new style when it attaches in
// _openInputConnection.
if
(
_
textInputConnection
!=
null
&&
_textInputConnection
!.
attached
)
{
if
(
_
hasInputConnection
)
{
_textInputConnection
!.
setStyle
(
fontFamily:
style
.
fontFamily
,
fontSize:
style
.
fontSize
,
...
...
packages/flutter/test/widgets/editable_text_test.dart
View file @
5024e1ea
...
...
@@ -1436,6 +1436,44 @@ void main() {
}
});
testWidgets
(
'Sends "updateConfig" when read-only flag is flipped'
,
(
WidgetTester
tester
)
async
{
bool
readOnly
=
true
;
StateSetter
setState
;
final
TextEditingController
controller
=
TextEditingController
(
text:
'Lorem ipsum dolor sit amet'
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
stateSetter
)
{
setState
=
stateSetter
;
return
EditableText
(
readOnly:
readOnly
,
controller:
controller
,
backgroundCursorColor:
Colors
.
grey
,
focusNode:
focusNode
,
style:
textStyle
,
cursorColor:
cursorColor
,
);
}),
),
);
// Interact with the field to establish the input connection.
final
Offset
topLeft
=
tester
.
getTopLeft
(
find
.
byType
(
EditableText
));
await
tester
.
tapAt
(
topLeft
+
const
Offset
(
0.0
,
5.0
));
await
tester
.
pump
();
expect
(
tester
.
testTextInput
.
hasAnyClients
,
kIsWeb
?
isTrue
:
isFalse
);
if
(
kIsWeb
)
{
expect
(
tester
.
testTextInput
.
setClientArgs
[
'readOnly'
],
isTrue
);
}
setState
(()
{
readOnly
=
false
;
});
await
tester
.
pump
();
expect
(
tester
.
testTextInput
.
hasAnyClients
,
isTrue
);
expect
(
tester
.
testTextInput
.
setClientArgs
[
'readOnly'
],
isFalse
);
});
testWidgets
(
'Fires onChanged when text changes via TextSelectionOverlay'
,
(
WidgetTester
tester
)
async
{
String
changedValue
;
final
Widget
widget
=
MaterialApp
(
...
...
packages/flutter_test/lib/src/test_text_input.dart
View file @
5024e1ea
...
...
@@ -98,6 +98,9 @@ class TestTextInput {
_client
=
methodCall
.
arguments
[
0
]
as
int
;
setClientArgs
=
methodCall
.
arguments
[
1
]
as
Map
<
String
,
dynamic
>;
break
;
case
'TextInput.updateConfig'
:
setClientArgs
=
methodCall
.
arguments
as
Map
<
String
,
dynamic
>;
break
;
case
'TextInput.clearClient'
:
_client
=
0
;
_isVisible
=
false
;
...
...
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