-
Notifications
You must be signed in to change notification settings - Fork 3.3k
go_router should allow setting requestFocus #4636
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
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
0f3bfa0
1
hannah-hyj fd8b12d
2
hannah-hyj e67036a
Update builder_test.dart
hannah-hyj 30eae56
Update shell_route.dart
hannah-hyj 68cd1a6
Create request_focus.dart
hannah-hyj 9b3a098
bump verstion
hannah-hyj 28fe484
Update pubspec.yaml
hannah-hyj 5e58db7
Update builder.dart
hannah-hyj b66dcfc
Update packages/go_router/lib/src/builder.dart
hannah-hyj 5576b21
resolve comments
hannah-hyj 7e10266
1
hannah-hyj 46d0169
Update router.dart
hannah-hyj fac1b21
Update router.dart
hannah-hyj 627d79e
Update test_helpers.dart
hannah-hyj bb50ce6
1
hannah-hyj 033a5ff
Update builder.dart
hannah-hyj f863e60
Merge branch 'main' of https://github.com/flutter/packages into 129581
hannah-hyj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 10.1.0 | ||
|
||
- Supports setting `requestFocus`. | ||
|
||
## 10.0.0 | ||
|
||
- **BREAKING CHANGE**: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:go_router/go_router.dart'; | ||
|
||
void main() { | ||
testWidgets('GoRouter does not request focus if requestFocus is false', | ||
(WidgetTester tester) async { | ||
final GlobalKey innerKey = GlobalKey(); | ||
final FocusScopeNode focusNode = FocusScopeNode(); | ||
final GoRouter router = GoRouter( | ||
initialLocation: '/', | ||
routes: <GoRoute>[ | ||
GoRoute( | ||
path: '/', | ||
name: 'home', | ||
builder: (_, __) => const Text('A'), | ||
), | ||
GoRoute( | ||
path: '/second', | ||
name: 'second', | ||
builder: (_, __) => Text('B', key: innerKey), | ||
), | ||
], | ||
requestFocus: false, | ||
); | ||
|
||
await tester.pumpWidget(Column( | ||
children: <Widget>[ | ||
FocusScope(node: focusNode, child: Container()), | ||
Expanded( | ||
child: MaterialApp.router( | ||
routerConfig: router, | ||
), | ||
), | ||
], | ||
)); | ||
|
||
expect(find.text('A'), findsOneWidget); | ||
expect(find.text('B', skipOffstage: false), findsNothing); | ||
expect(focusNode.hasFocus, false); | ||
focusNode.requestFocus(); | ||
await tester.pumpAndSettle(); | ||
expect(focusNode.hasFocus, true); | ||
|
||
router.pushNamed('second'); | ||
await tester.pumpAndSettle(); | ||
expect(find.text('A', skipOffstage: false), findsOneWidget); | ||
expect(find.text('B'), findsOneWidget); | ||
expect(focusNode.hasFocus, true); | ||
|
||
router.pop(); | ||
await tester.pumpAndSettle(); | ||
expect(find.text('A'), findsOneWidget); | ||
expect(find.text('B', skipOffstage: false), findsNothing); | ||
expect(focusNode.hasFocus, true); | ||
}); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a link to navigator.requestfocus
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done