Clear the pointer absorbing flag after temporarily setting it while popping a route (#5036)

Fixes https://github.com/flutter/flutter/issues/4910
This commit is contained in:
Jason Simmons
2016-07-26 11:13:34 -07:00
committed by GitHub
parent 76ea70a123
commit 3b577c537c
2 changed files with 53 additions and 1 deletions

View File

@@ -492,7 +492,9 @@ class NavigatorState extends State<Navigator> {
// This mechanism is far from perfect. See the issue below for more details:
// https://github.com/flutter/flutter/issues/4770
RenderAbsorbPointer absorber = _overlayKey.currentContext?.ancestorRenderObjectOfType(const TypeMatcher<RenderAbsorbPointer>());
absorber?.absorbing = true;
setState(() {
absorber?.absorbing = true;
});
for (int pointer in _activePointers.toList())
WidgetsBinding.instance.cancelPointer(pointer);
}

View File

@@ -124,4 +124,54 @@ void main() {
await gesture.up();
});
testWidgets('Drawer navigator back button', (WidgetTester tester) async {
GlobalKey<ScaffoldState> scaffoldKey = new GlobalKey<ScaffoldState>();
bool buttonPressed = false;
await tester.pumpWidget(
new MaterialApp(
home: new Builder(
builder: (BuildContext context) {
return new Scaffold(
key: scaffoldKey,
drawer: new Drawer(
child: new Block(
children: <Widget>[
new Text('drawer'),
new FlatButton(
child: new Text('close'),
onPressed: () => Navigator.pop(context)
),
]
)
),
body: new Container(
child: new FlatButton(
child: new Text('button'),
onPressed: () { buttonPressed = true; }
)
)
);
}
)
)
);
// Open the drawer.
scaffoldKey.currentState.openDrawer();
await tester.pump(); // drawer should be starting to animate in
expect(find.text('drawer'), findsOneWidget);
// Tap the close button to pop the drawer route.
await tester.pump(new Duration(milliseconds: 100));
await tester.tap(find.text('close'));
await tester.pump();
await tester.pump(new Duration(seconds: 1));
expect(find.text('drawer'), findsNothing);
// Confirm that a button in the scaffold body is still clickable.
await tester.tap(find.text('button'));
expect(buttonPressed, equals(true));
});
}