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
e6f2bc86
Unverified
Commit
e6f2bc86
authored
Mar 17, 2021
by
William Oprandi
Committed by
GitHub
Mar 17, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FocusableActionDetector now exposes descendantsAreFocusable property (#77288)
parent
b35fbfec
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
0 deletions
+49
-0
actions.dart
packages/flutter/lib/src/widgets/actions.dart
+5
-0
actions_test.dart
packages/flutter/test/widgets/actions_test.dart
+44
-0
No files found.
packages/flutter/lib/src/widgets/actions.dart
View file @
e6f2bc86
...
...
@@ -1246,6 +1246,7 @@ class FocusableActionDetector extends StatefulWidget {
this
.
enabled
=
true
,
this
.
focusNode
,
this
.
autofocus
=
false
,
this
.
descendantsAreFocusable
=
true
,
this
.
shortcuts
,
this
.
actions
,
this
.
onShowFocusHighlight
,
...
...
@@ -1274,6 +1275,9 @@ class FocusableActionDetector extends StatefulWidget {
/// {@macro flutter.widgets.Focus.autofocus}
final
bool
autofocus
;
/// {@macro flutter.widgets.Focus.descendantsAreFocusable}
final
bool
descendantsAreFocusable
;
/// {@macro flutter.widgets.actions.actions}
final
Map
<
Type
,
Action
<
Intent
>>?
actions
;
...
...
@@ -1459,6 +1463,7 @@ class _FocusableActionDetectorState extends State<FocusableActionDetector> {
child:
Focus
(
focusNode:
widget
.
focusNode
,
autofocus:
widget
.
autofocus
,
descendantsAreFocusable:
widget
.
descendantsAreFocusable
,
canRequestFocus:
_canRequestFocus
,
onFocusChange:
_handleFocusChange
,
child:
widget
.
child
,
...
...
packages/flutter/test/widgets/actions_test.dart
View file @
e6f2bc86
...
...
@@ -919,6 +919,50 @@ void main() {
expect
(
hovering
,
isFalse
);
expect
(
focusing
,
isFalse
);
});
testWidgets
(
'FocusableActionDetector can prevent its descendants from being focusable'
,
(
WidgetTester
tester
)
async
{
final
FocusNode
buttonNode
=
FocusNode
(
debugLabel:
'Test'
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
FocusableActionDetector
(
descendantsAreFocusable:
true
,
child:
MaterialButton
(
focusNode:
buttonNode
,
child:
const
Text
(
'Test'
),
onPressed:
()
{},
),
),
),
);
// Button is focusable
expect
(
buttonNode
.
hasFocus
,
isFalse
);
buttonNode
.
requestFocus
();
await
tester
.
pump
();
expect
(
buttonNode
.
hasFocus
,
isTrue
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
FocusableActionDetector
(
descendantsAreFocusable:
false
,
child:
MaterialButton
(
focusNode:
buttonNode
,
child:
const
Text
(
'Test'
),
onPressed:
()
{},
),
),
),
);
// Button is NOT focusable
expect
(
buttonNode
.
hasFocus
,
isFalse
);
buttonNode
.
requestFocus
();
await
tester
.
pump
();
expect
(
buttonNode
.
hasFocus
,
isFalse
);
});
});
group
(
'Diagnostics'
,
()
{
...
...
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