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
1361071a
Unverified
Commit
1361071a
authored
May 25, 2018
by
Michael Goderbauer
Committed by
GitHub
May 25, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't crash when TextField w/ explicit controller is activated via a11y (#17892)
Fixes #17801.
parent
c4d6311a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
2 deletions
+72
-2
text_field.dart
packages/flutter/lib/src/material/text_field.dart
+2
-2
text_field_test.dart
packages/flutter/test/material/text_field_test.dart
+70
-0
No files found.
packages/flutter/lib/src/material/text_field.dart
View file @
1361071a
...
...
@@ -506,8 +506,8 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
return
new
Semantics
(
onTap:
()
{
if
(!
_
c
ontroller
.
selection
.
isValid
)
_
controller
.
selection
=
new
TextSelection
.
collapsed
(
offset:
_c
ontroller
.
text
.
length
);
if
(!
_
effectiveC
ontroller
.
selection
.
isValid
)
_
effectiveController
.
selection
=
new
TextSelection
.
collapsed
(
offset:
_effectiveC
ontroller
.
text
.
length
);
_requestKeyboard
();
},
child:
new
IgnorePointer
(
...
...
packages/flutter/test/material/text_field_test.dart
View file @
1361071a
...
...
@@ -2059,6 +2059,76 @@ void main() {
semantics
.
dispose
();
});
testWidgets
(
'Can activate TextField with explicit controller via semantics '
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/17801
const
String
textInTextField
=
'Hello'
;
final
SemanticsTester
semantics
=
new
SemanticsTester
(
tester
);
final
SemanticsOwner
semanticsOwner
=
tester
.
binding
.
pipelineOwner
.
semanticsOwner
;
final
TextEditingController
controller
=
new
TextEditingController
()
..
text
=
textInTextField
;
final
Key
key
=
new
UniqueKey
();
await
tester
.
pumpWidget
(
overlay
(
child:
new
TextField
(
key:
key
,
controller:
controller
,
),
),
);
const
int
inputFieldId
=
1
;
expect
(
semantics
,
hasSemantics
(
new
TestSemantics
.
root
(
children:
<
TestSemantics
>[
new
TestSemantics
(
id:
inputFieldId
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isTextField
],
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
],
value:
textInTextField
,
textDirection:
TextDirection
.
ltr
,
),
],
),
ignoreRect:
true
,
ignoreTransform:
true
,
));
semanticsOwner
.
performAction
(
inputFieldId
,
SemanticsAction
.
tap
);
await
tester
.
pump
();
expect
(
semantics
,
hasSemantics
(
new
TestSemantics
.
root
(
children:
<
TestSemantics
>[
new
TestSemantics
(
id:
inputFieldId
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isTextField
,
SemanticsFlag
.
isFocused
,
],
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
,
SemanticsAction
.
moveCursorBackwardByCharacter
,
SemanticsAction
.
setSelection
,
SemanticsAction
.
paste
,
],
value:
textInTextField
,
textDirection:
TextDirection
.
ltr
,
textSelection:
const
TextSelection
(
baseOffset:
textInTextField
.
length
,
extentOffset:
textInTextField
.
length
,
),
),
],
),
ignoreRect:
true
,
ignoreTransform:
true
,
));
semantics
.
dispose
();
});
testWidgets
(
'TextField throws when not descended from a Material widget'
,
(
WidgetTester
tester
)
async
{
const
Widget
textField
=
const
TextField
();
await
tester
.
pumpWidget
(
textField
);
...
...
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