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
3c278518
Unverified
Commit
3c278518
authored
Nov 05, 2021
by
JBBx2016
Committed by
GitHub
Nov 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes issue where navigating to new route breaks FocusNode of previou… (#92615)
parent
15d0a8be
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
4 deletions
+35
-4
focus_scope.dart
packages/flutter/lib/src/widgets/focus_scope.dart
+4
-4
focus_scope_test.dart
packages/flutter/test/widgets/focus_scope_test.dart
+31
-0
No files found.
packages/flutter/lib/src/widgets/focus_scope.dart
View file @
3c278518
...
@@ -488,8 +488,8 @@ class _FocusState extends State<Focus> {
...
@@ -488,8 +488,8 @@ class _FocusState extends State<Focus> {
if
(
widget
.
skipTraversal
!=
null
)
{
if
(
widget
.
skipTraversal
!=
null
)
{
focusNode
.
skipTraversal
=
widget
.
skipTraversal
;
focusNode
.
skipTraversal
=
widget
.
skipTraversal
;
}
}
if
(
widget
.
canRequestFocus
!=
null
)
{
if
(
widget
.
_
canRequestFocus
!=
null
)
{
focusNode
.
canRequestFocus
=
widget
.
canRequestFocus
;
focusNode
.
canRequestFocus
=
widget
.
_canRequestFocus
!
;
}
}
_couldRequestFocus
=
focusNode
.
canRequestFocus
;
_couldRequestFocus
=
focusNode
.
canRequestFocus
;
_descendantsWereFocusable
=
focusNode
.
descendantsAreFocusable
;
_descendantsWereFocusable
=
focusNode
.
descendantsAreFocusable
;
...
@@ -575,8 +575,8 @@ class _FocusState extends State<Focus> {
...
@@ -575,8 +575,8 @@ class _FocusState extends State<Focus> {
if
(
widget
.
skipTraversal
!=
null
)
{
if
(
widget
.
skipTraversal
!=
null
)
{
focusNode
.
skipTraversal
=
widget
.
skipTraversal
;
focusNode
.
skipTraversal
=
widget
.
skipTraversal
;
}
}
if
(
widget
.
canRequestFocus
!=
null
)
{
if
(
widget
.
_
canRequestFocus
!=
null
)
{
focusNode
.
canRequestFocus
=
widget
.
canRequestFocus
;
focusNode
.
canRequestFocus
=
widget
.
_canRequestFocus
!
;
}
}
focusNode
.
descendantsAreFocusable
=
widget
.
descendantsAreFocusable
;
focusNode
.
descendantsAreFocusable
=
widget
.
descendantsAreFocusable
;
}
}
...
...
packages/flutter/test/widgets/focus_scope_test.dart
View file @
3c278518
...
@@ -1925,5 +1925,36 @@ void main() {
...
@@ -1925,5 +1925,36 @@ void main() {
final
TestSemantics
expectedSemantics
=
TestSemantics
.
root
();
final
TestSemantics
expectedSemantics
=
TestSemantics
.
root
();
expect
(
semantics
,
hasSemantics
(
expectedSemantics
));
expect
(
semantics
,
hasSemantics
(
expectedSemantics
));
});
});
// Regression test for https://github.com/flutter/flutter/issues/92693
testWidgets
(
'Setting parent FocusScope.canRequestFocus to false, does not set descendant Focus._internalNode._canRequestFocus to false'
,
(
WidgetTester
tester
)
async
{
final
FocusNode
childFocusNode
=
FocusNode
(
debugLabel:
'node 1'
);
Widget
buildFocusTree
({
required
bool
parentCanRequestFocus
})
{
return
FocusScope
(
canRequestFocus:
parentCanRequestFocus
,
child:
Column
(
children:
<
Widget
>[
Focus
(
focusNode:
childFocusNode
,
child:
Container
(),
),
],
),
);
}
// childFocusNode.canRequestFocus is true when parent canRequestFocus is true
await
tester
.
pumpWidget
(
buildFocusTree
(
parentCanRequestFocus:
true
));
expect
(
childFocusNode
.
canRequestFocus
,
isTrue
);
// childFocusNode.canRequestFocus is false when parent canRequestFocus is false
await
tester
.
pumpWidget
(
buildFocusTree
(
parentCanRequestFocus:
false
));
expect
(
childFocusNode
.
canRequestFocus
,
isFalse
);
// childFocusNode.canRequestFocus is true again when parent canRequestFocus is changed back to true
await
tester
.
pumpWidget
(
buildFocusTree
(
parentCanRequestFocus:
true
));
expect
(
childFocusNode
.
canRequestFocus
,
isTrue
);
});
});
});
}
}
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