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
cb906179
Unverified
Commit
cb906179
authored
Jun 04, 2019
by
Todd Volkert
Committed by
GitHub
Jun 04, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "ModalRoute resumes previous focus on didPopNext (#33152)" (#33815)
This reverts commit
0f2254a5
.
parent
9734f4ed
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
58 deletions
+5
-58
routes.dart
packages/flutter/lib/src/widgets/routes.dart
+0
-11
text_field_focus_test.dart
packages/flutter/test/material/text_field_focus_test.dart
+5
-0
routes_test.dart
packages/flutter/test/widgets/routes_test.dart
+0
-47
No files found.
packages/flutter/lib/src/widgets/routes.dart
View file @
cb906179
...
...
@@ -1086,17 +1086,6 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
return
await
super
.
willPop
();
}
@override
void
didPopNext
(
Route
<
dynamic
>
nextRoute
)
{
super
.
didPopNext
(
nextRoute
);
// When the route on top of this route is popped, resume focus onto the
// widget that received the last focus.
final
_ModalScopeState
<
T
>
modalScopeState
=
_scopeKey
.
currentState
;
if
(
modalScopeState
!=
null
)
{
modalScopeState
.
focusScopeNode
.
requestFocus
();
}
}
/// Enables this route to veto attempts by the user to dismiss it.
///
/// This callback is typically added using a [WillPopScope] widget. That
...
...
packages/flutter/test/material/text_field_focus_test.dart
View file @
cb906179
...
...
@@ -40,6 +40,11 @@ void main() {
Navigator
.
of
(
tester
.
element
(
find
.
text
(
'Dialog'
))).
pop
();
await
tester
.
pump
();
expect
(
tester
.
testTextInput
.
isVisible
,
isFalse
);
await
tester
.
tap
(
find
.
byType
(
TextField
));
await
tester
.
idle
();
expect
(
tester
.
testTextInput
.
isVisible
,
isTrue
);
await
tester
.
pumpWidget
(
Container
());
...
...
packages/flutter/test/widgets/routes_test.dart
View file @
cb906179
...
...
@@ -8,7 +8,6 @@ import 'package:flutter/foundation.dart';
import
'package:mockito/mockito.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/material.dart'
;
final
List
<
String
>
results
=
<
String
>[];
...
...
@@ -504,52 +503,6 @@ void main() {
verifyNoMoreInteractions
(
pageRouteAware
);
});
});
group
(
'ModalRoute'
,
()
{
testWidgets
(
'should resume focus when the next route is popped'
,
(
WidgetTester
tester
)
async
{
// TODO(tongmu): It's currently using PageRoute (from MaterialApp)
// instead of ModalRoute, which might leave a risk but avoids building
// everything from scratch by using the existing setup by MaterialApp and
// TextField as a focusable widget. We might want to write a better test.
final
FocusNode
node
=
FocusNode
();
BuildContext
pageContext
;
final
Widget
widget
=
MaterialApp
(
theme:
ThemeData
(),
home:
Material
(
child:
Builder
(
builder:
(
BuildContext
context
)
{
pageContext
=
context
;
return
Column
(
children:
<
Widget
>[
const
TextField
(),
TextField
(
focusNode:
node
),
],
);
}
),
),
);
await
tester
.
pumpWidget
(
widget
);
expect
(
node
.
hasFocus
,
false
);
node
.
requestFocus
();
await
tester
.
pumpAndSettle
();
expect
(
node
.
hasFocus
,
true
);
showDialog
<
void
>(
context:
pageContext
,
builder:
(
BuildContext
_
)
=>
const
Center
(),
);
await
tester
.
pumpAndSettle
();
expect
(
node
.
hasFocus
,
false
);
Navigator
.
of
(
pageContext
).
pop
();
await
tester
.
pumpAndSettle
();
expect
(
node
.
hasFocus
,
true
);
});
});
}
class
MockPageRoute
extends
Mock
implements
PageRoute
<
dynamic
>
{
}
...
...
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