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
dd41f41f
Unverified
Commit
dd41f41f
authored
Oct 12, 2020
by
xubaolin
Committed by
GitHub
Oct 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CupertinoTextField should not accept requestFocus when disabled (#65235)
parent
408cd71d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
5 deletions
+39
-5
text_field.dart
packages/flutter/lib/src/cupertino/text_field.dart
+2
-5
text_field_test.dart
packages/flutter/test/cupertino/text_field_test.dart
+37
-0
No files found.
packages/flutter/lib/src/cupertino/text_field.dart
View file @
dd41f41f
...
...
@@ -653,6 +653,7 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio
if
(
widget
.
controller
==
null
)
{
_createLocalController
();
}
_effectiveFocusNode
.
canRequestFocus
=
widget
.
enabled
??
true
;
}
@override
...
...
@@ -665,11 +666,7 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio
_controller
!.
dispose
();
_controller
=
null
;
}
final
bool
isEnabled
=
widget
.
enabled
??
true
;
final
bool
wasEnabled
=
oldWidget
.
enabled
??
true
;
if
(
wasEnabled
&&
!
isEnabled
)
{
_effectiveFocusNode
.
unfocus
();
}
_effectiveFocusNode
.
canRequestFocus
=
widget
.
enabled
??
true
;
}
@override
...
...
packages/flutter/test/cupertino/text_field_test.dart
View file @
dd41f41f
...
...
@@ -2707,6 +2707,43 @@ void main() {
expect
(
tapCount
,
1
);
});
testWidgets
(
'Focus test when the text field is disabled'
,
(
WidgetTester
tester
)
async
{
final
FocusNode
focusNode
=
FocusNode
();
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
Center
(
child:
CupertinoTextField
(
focusNode:
focusNode
,
),
),
),
);
expect
(
focusNode
.
hasFocus
,
false
);
// initial status
// Should accept requestFocus.
focusNode
.
requestFocus
();
await
tester
.
pump
();
expect
(
focusNode
.
hasFocus
,
true
);
// Disable the text field, now it should not accept requestFocus.
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
Center
(
child:
CupertinoTextField
(
enabled:
false
,
focusNode:
focusNode
,
),
),
),
);
// Should not accept requestFocus.
focusNode
.
requestFocus
();
await
tester
.
pump
();
expect
(
focusNode
.
hasFocus
,
false
);
});
testWidgets
(
'text field respects theme'
,
(
WidgetTester
tester
)
async
{
...
...
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