这是indexloc提供的服务,不要输入任何密码
Skip to content

Fix an exception being thrown when focus groups are empty. #86734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 20, 2021

Conversation

gspencergoog
Copy link
Contributor

Description

When a focus traversal group has no entries, but traversal is requested, we were throwing an exception because we couldn't find the group marker's scope in the list of candidates. This fixes that, and adds a test.

Related Issues

Tests

  • Added a test to make sure that an empty group doesn't throw when traversal is requested.

@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Jul 20, 2021
@google-cla google-cla bot added the cla: yes label Jul 20, 2021
@gspencergoog gspencergoog requested a review from goderbauer July 20, 2021 18:44
@skia-gold
Copy link

Gold has detected about 2 new digest(s) on patchset 1.
View them at https://flutter-gold.skia.org/cl/github/86734

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -2015,6 +2015,11 @@ void main() {
expect(events.length, 2);
});

testWidgets('Focus traversal does not throw when no focusable is available in a group', (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp(home: Scaffold(body: ListTile(title: Text('title')))));
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we assert somehow that "nothing" has focus or that the focus stayed where it was even after the tab was send?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Done.

@skia-gold
Copy link

Gold has detected about 4 new digest(s) on patchset 2.
View them at https://flutter-gold.skia.org/cl/github/86734

@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #86734 at sha 62ce761

@flutter-dashboard flutter-dashboard bot added the will affect goldens Changes to golden files label Jul 20, 2021
@gspencergoog gspencergoog merged commit 2b7b4bd into flutter:master Jul 20, 2021
@gspencergoog gspencergoog deleted the focus_traversal_throws branch July 20, 2021 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
framework flutter/packages/flutter repository. See also f: labels. will affect goldens Changes to golden files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[desktop] FocusTraversalPolicy._sortAllDescendants crashes/throws error when tab to focus on unfocusable widgets
3 participants