Unverified Commit 12ec91a5 authored by Aliaksei Chorny's avatar Aliaksei Chorny Committed by GitHub

The covered child in AnimatedCrossFade should not get touch events (#91349)

parent 15de4aa4
...@@ -342,6 +342,7 @@ class _AnimatedCrossFadeState extends State<AnimatedCrossFade> with TickerProvid ...@@ -342,6 +342,7 @@ class _AnimatedCrossFadeState extends State<AnimatedCrossFade> with TickerProvid
bottomChild = TickerMode( bottomChild = TickerMode(
key: bottomKey, key: bottomKey,
enabled: _isTransitioning, enabled: _isTransitioning,
child: IgnorePointer(
child: ExcludeSemantics( // Always exclude the semantics of the widget that's fading out. child: ExcludeSemantics( // Always exclude the semantics of the widget that's fading out.
child: ExcludeFocus( child: ExcludeFocus(
child: FadeTransition( child: FadeTransition(
...@@ -350,10 +351,13 @@ class _AnimatedCrossFadeState extends State<AnimatedCrossFade> with TickerProvid ...@@ -350,10 +351,13 @@ class _AnimatedCrossFadeState extends State<AnimatedCrossFade> with TickerProvid
), ),
), ),
), ),
),
); );
topChild = TickerMode( topChild = TickerMode(
key: topKey, key: topKey,
enabled: true, // Top widget always has its animations enabled. enabled: true, // Top widget always has its animations enabled.
child: IgnorePointer(
ignoring: false,
child: ExcludeSemantics( child: ExcludeSemantics(
excluding: false, // Always publish semantics for the widget that's fading in. excluding: false, // Always publish semantics for the widget that's fading in.
child: ExcludeFocus( child: ExcludeFocus(
...@@ -364,6 +368,7 @@ class _AnimatedCrossFadeState extends State<AnimatedCrossFade> with TickerProvid ...@@ -364,6 +368,7 @@ class _AnimatedCrossFadeState extends State<AnimatedCrossFade> with TickerProvid
), ),
), ),
), ),
),
); );
return ClipRect( return ClipRect(
child: AnimatedSize( child: AnimatedSize(
......
...@@ -384,6 +384,53 @@ void main() { ...@@ -384,6 +384,53 @@ void main() {
await tester.pump(); await tester.pump();
expect(hiddenNode.hasPrimaryFocus, isFalse); expect(hiddenNode.hasPrimaryFocus, isFalse);
}); });
testWidgets('AnimatedCrossFade second child do not receive touch events',
(WidgetTester tester) async {
int numberOfTouchEventNoticed = 0;
Future<void> buildAnimatedFrame(CrossFadeState crossFadeState) {
return tester.pumpWidget(
SizedBox(
width: 300,
height: 600,
child: Directionality(
textDirection: TextDirection.ltr,
child: AnimatedCrossFade(
firstChild: const Text('AAA'),
secondChild: TextButton(
style: TextButton.styleFrom(minimumSize: const Size(double.infinity, 600)),
onPressed: () {
numberOfTouchEventNoticed++;
},
child: const Text('BBB'),
),
crossFadeState: crossFadeState,
duration: const Duration(milliseconds: 50),
),
),
),
);
}
Future<void> touchSecondButton() async {
final TestGesture gestureTouchSecondButton = await tester
.startGesture(const Offset(150, 300));
return gestureTouchSecondButton.up();
}
await buildAnimatedFrame(CrossFadeState.showSecond);
await touchSecondButton();
expect(numberOfTouchEventNoticed, 1);
await buildAnimatedFrame(CrossFadeState.showFirst);
await touchSecondButton();
await touchSecondButton();
expect(numberOfTouchEventNoticed, 1);
});
} }
class _TickerWatchingWidget extends StatefulWidget { class _TickerWatchingWidget extends StatefulWidget {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment