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
736b414f
Unverified
Commit
736b414f
authored
Nov 14, 2017
by
Michael Goderbauer
Committed by
GitHub
Nov 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add text field content to semantics (#13000)
* Add text field content to semantics * remove controller dup
parent
62ed4f59
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
1 deletion
+50
-1
editable.dart
packages/flutter/lib/src/rendering/editable.dart
+4
-0
editable_text_test.dart
packages/flutter/test/widgets/editable_text_test.dart
+37
-0
semantics_tester.dart
packages/flutter/test/widgets/semantics_tester.dart
+9
-1
No files found.
packages/flutter/lib/src/rendering/editable.dart
View file @
736b414f
...
@@ -169,6 +169,7 @@ class RenderEditable extends RenderBox {
...
@@ -169,6 +169,7 @@ class RenderEditable extends RenderBox {
return
;
return
;
_textPainter
.
text
=
value
;
_textPainter
.
text
=
value
;
markNeedsTextLayout
();
markNeedsTextLayout
();
markNeedsSemanticsUpdate
();
}
}
/// How the text should be aligned horizontally.
/// How the text should be aligned horizontally.
...
@@ -203,6 +204,7 @@ class RenderEditable extends RenderBox {
...
@@ -203,6 +204,7 @@ class RenderEditable extends RenderBox {
return
;
return
;
_textPainter
.
textDirection
=
value
;
_textPainter
.
textDirection
=
value
;
markNeedsTextLayout
();
markNeedsTextLayout
();
markNeedsSemanticsUpdate
();
}
}
/// The color to use when painting the cursor.
/// The color to use when painting the cursor.
...
@@ -322,6 +324,8 @@ class RenderEditable extends RenderBox {
...
@@ -322,6 +324,8 @@ class RenderEditable extends RenderBox {
super
.
describeSemanticsConfiguration
(
config
);
super
.
describeSemanticsConfiguration
(
config
);
config
config
..
value
=
text
.
toPlainText
()
..
textDirection
=
textDirection
..
isFocused
=
hasFocus
..
isFocused
=
hasFocus
..
isTextField
=
true
;
..
isTextField
=
true
;
}
}
...
...
packages/flutter/test/widgets/editable_text_test.dart
View file @
736b414f
...
@@ -284,6 +284,43 @@ void main() {
...
@@ -284,6 +284,43 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
semantics
,
includesNodeWith
(
flags:
<
SemanticsFlags
>[
SemanticsFlags
.
isTextField
,
SemanticsFlags
.
isFocused
]));
expect
(
semantics
,
includesNodeWith
(
flags:
<
SemanticsFlags
>[
SemanticsFlags
.
isTextField
,
SemanticsFlags
.
isFocused
]));
});
testWidgets
(
'EditableText includes text as value in semantics'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
new
SemanticsTester
(
tester
);
const
String
value1
=
'EditableText content'
;
controller
.
text
=
value1
;
await
tester
.
pumpWidget
(
new
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
new
FocusScope
(
node:
focusScopeNode
,
child:
new
EditableText
(
controller:
controller
,
focusNode:
focusNode
,
style:
textStyle
,
cursorColor:
cursorColor
,
),
),
),
);
expect
(
semantics
,
includesNodeWith
(
flags:
<
SemanticsFlags
>[
SemanticsFlags
.
isTextField
],
value:
value1
,
));
const
String
value2
=
'Changed the EditableText content'
;
controller
.
text
=
value2
;
await
tester
.
idle
();
await
tester
.
pump
();
expect
(
semantics
,
includesNodeWith
(
flags:
<
SemanticsFlags
>[
SemanticsFlags
.
isTextField
],
value:
value2
,
));
});
});
}
}
packages/flutter/test/widgets/semantics_tester.dart
View file @
736b414f
...
@@ -314,12 +314,14 @@ Matcher hasSemantics(TestSemantics semantics, {
...
@@ -314,12 +314,14 @@ Matcher hasSemantics(TestSemantics semantics, {
class
_IncludesNodeWith
extends
Matcher
{
class
_IncludesNodeWith
extends
Matcher
{
const
_IncludesNodeWith
({
const
_IncludesNodeWith
({
this
.
label
,
this
.
label
,
this
.
value
,
this
.
textDirection
,
this
.
textDirection
,
this
.
actions
,
this
.
actions
,
this
.
flags
,
this
.
flags
,
})
:
assert
(
label
!=
null
||
actions
!=
null
||
flags
!=
null
);
})
:
assert
(
label
!=
null
||
value
!=
null
||
actions
!=
null
||
flags
!=
null
);
final
String
label
;
final
String
label
;
final
String
value
;
final
TextDirection
textDirection
;
final
TextDirection
textDirection
;
final
List
<
SemanticsAction
>
actions
;
final
List
<
SemanticsAction
>
actions
;
final
List
<
SemanticsFlags
>
flags
;
final
List
<
SemanticsFlags
>
flags
;
...
@@ -344,6 +346,8 @@ class _IncludesNodeWith extends Matcher {
...
@@ -344,6 +346,8 @@ class _IncludesNodeWith extends Matcher {
bool
checkNode
(
SemanticsNode
node
)
{
bool
checkNode
(
SemanticsNode
node
)
{
if
(
label
!=
null
&&
node
.
label
!=
label
)
if
(
label
!=
null
&&
node
.
label
!=
label
)
return
false
;
return
false
;
if
(
value
!=
null
&&
node
.
value
!=
value
)
return
false
;
if
(
textDirection
!=
null
&&
node
.
textDirection
!=
textDirection
)
if
(
textDirection
!=
null
&&
node
.
textDirection
!=
textDirection
)
return
false
;
return
false
;
if
(
actions
!=
null
)
{
if
(
actions
!=
null
)
{
...
@@ -375,6 +379,8 @@ class _IncludesNodeWith extends Matcher {
...
@@ -375,6 +379,8 @@ class _IncludesNodeWith extends Matcher {
final
List
<
String
>
strings
=
<
String
>[];
final
List
<
String
>
strings
=
<
String
>[];
if
(
label
!=
null
)
if
(
label
!=
null
)
strings
.
add
(
'label "
$label
"'
);
strings
.
add
(
'label "
$label
"'
);
if
(
value
!=
null
)
strings
.
add
(
'value "
$value
"'
);
if
(
textDirection
!=
null
)
if
(
textDirection
!=
null
)
strings
.
add
(
' (
${describeEnum(textDirection)}
)'
);
strings
.
add
(
' (
${describeEnum(textDirection)}
)'
);
if
(
actions
!=
null
)
if
(
actions
!=
null
)
...
@@ -391,12 +397,14 @@ class _IncludesNodeWith extends Matcher {
...
@@ -391,12 +397,14 @@ class _IncludesNodeWith extends Matcher {
/// If null is provided for an argument, it will match against any value.
/// If null is provided for an argument, it will match against any value.
Matcher
includesNodeWith
(
{
Matcher
includesNodeWith
(
{
String
label
,
String
label
,
String
value
,
TextDirection
textDirection
,
TextDirection
textDirection
,
List
<
SemanticsAction
>
actions
,
List
<
SemanticsAction
>
actions
,
List
<
SemanticsFlags
>
flags
,
List
<
SemanticsFlags
>
flags
,
})
{
})
{
return
new
_IncludesNodeWith
(
return
new
_IncludesNodeWith
(
label:
label
,
label:
label
,
value:
value
,
textDirection:
textDirection
,
textDirection:
textDirection
,
actions:
actions
,
actions:
actions
,
flags:
flags
,
flags:
flags
,
...
...
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