-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsf: focusFocus traversal, gaining or losing focusFocus traversal, gaining or losing focusfound in release: 3.19Found to occur in 3.19Found to occur in 3.19found in release: 3.22Found to occur in 3.22Found to occur in 3.22frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
Happens with current main (3.22.0-16.0.pre.26).
Widget test to reproduce:
testWidgets('FocusScope descendantsAreFocusable', (WidgetTester tester) async {
final focusScopeNode = FocusScopeNode();
await tester.pumpWidget(
FocusScope(
node: focusScopeNode,
child: const SizedBox.shrink(),
),
);
expect(focusScopeNode.descendantsAreFocusable, isTrue);
focusScopeNode.canRequestFocus = false;
expect(focusScopeNode.descendantsAreFocusable, isFalse);
focusScopeNode.canRequestFocus = true;
expect(focusScopeNode.descendantsAreFocusable, isTrue);
// Disabling canRequestFocus and updating the widget will permanently disable descendantsAreFocusable.
focusScopeNode.canRequestFocus = false;
// After this pump, setting canRequestFocus back will not restore
// descendantsAreFocusable to true.
await tester.pumpWidget(
FocusScope(
node: focusScopeNode,
child: const SizedBox.shrink(),
),
);
focusScopeNode.canRequestFocus = true;
// Test failure:
// This should be back to true, but in FocusNode state didUpdateWidget the
// descendantsAreFocusable on the focusScopeNode got set to false.
expect(focusScopeNode.descendantsAreFocusable, isTrue);
});This break focus in _ModalScopeState which sets canRequestFocus on the scope node and then rebuilds widget, which in turns sets the descendantsAreFocusable to false.
@gspencergoog, any thoughts? The focus code is quite convoluted, in this case the _FocusState.didUpdateWidget actually overrides property on FocusScopeNode, which is quite surprising.
CillianMyles and siddharthadevops
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsf: focusFocus traversal, gaining or losing focusFocus traversal, gaining or losing focusfound in release: 3.19Found to occur in 3.19Found to occur in 3.19found in release: 3.22Found to occur in 3.22Found to occur in 3.22frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team