mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-11-21 20:00:49 +01:00
fix(motion): move focus off the shell when Now Playing opens
The transition keeps the shell painted through the entrance, so its Visibility no longer excluded focus at once: a search field left focused underneath kept taking Space for up to half a second. Exclude focus from the shell while Now Playing is open and from Now Playing while it leaves, as before the transition.
This commit is contained in:
1 parent
f652b57d07
commit
bd606dabe4
2 files changed
+52
-9
No files matched your search
@@ -452,19 +452,28 @@ class _NowPlayingTransitionState extends State<_NowPlayingTransition>
|
||||
Visibility(
|
||||
visible: !covered,
|
||||
maintainState: true,
|
||||
child: IgnorePointer(ignoring: widget.open, child: widget.shell),
|
||||
// Focus leaves the shell as soon as Now Playing opens, and leaves
|
||||
// Now Playing as soon as it closes, as without the transition, so
|
||||
// a field left focused underneath cannot take Space meanwhile.
|
||||
child: IgnorePointer(
|
||||
ignoring: widget.open,
|
||||
child: ExcludeFocus(excluding: widget.open, child: widget.shell),
|
||||
),
|
||||
),
|
||||
if (widget.open || !_controller.isDismissed)
|
||||
IgnorePointer(
|
||||
ignoring: exiting,
|
||||
child: Transform.translate(
|
||||
offset: Offset(0, offset),
|
||||
child: Opacity(
|
||||
key: const ValueKey('desktop-now-playing-fade'),
|
||||
opacity: opacity.clamp(0.0, 1.0),
|
||||
child: KeyedSubtree(
|
||||
key: const ValueKey('desktop-now-playing'),
|
||||
child: widget.nowPlaying,
|
||||
child: ExcludeFocus(
|
||||
excluding: exiting,
|
||||
child: Transform.translate(
|
||||
offset: Offset(0, offset),
|
||||
child: Opacity(
|
||||
key: const ValueKey('desktop-now-playing-fade'),
|
||||
opacity: opacity.clamp(0.0, 1.0),
|
||||
child: KeyedSubtree(
|
||||
key: const ValueKey('desktop-now-playing'),
|
||||
child: widget.nowPlaying,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -417,6 +417,40 @@ void main() {
|
||||
expect(find.text('content'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('focus leaves the shell as soon as Now Playing opens '
|
||||
'($mornye)', (tester) async {
|
||||
addTearDown(() => desktopNowPlayingOpen.value = false);
|
||||
await pumpShell(
|
||||
tester,
|
||||
mornye: mornye,
|
||||
width: 1400,
|
||||
nowPlaying: const ColoredBox(color: Colors.black),
|
||||
);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
|
||||
await tester.pump();
|
||||
final shellFocus = FocusManager.instance.primaryFocus!;
|
||||
expect(
|
||||
shellFocus.context!.findAncestorWidgetOfExactType<DesktopShellLayout>(),
|
||||
isNotNull,
|
||||
);
|
||||
|
||||
desktopNowPlayingOpen.value = true;
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 16));
|
||||
// Still mid-entrance, with the shell painted underneath.
|
||||
expect(find.text('content'), findsOneWidget);
|
||||
expect(shellFocus.hasPrimaryFocus, isFalse);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
desktopNowPlayingOpen.value = false;
|
||||
await tester.pump();
|
||||
// The shell takes focus again while Now Playing leaves.
|
||||
shellFocus.requestFocus();
|
||||
await tester.pump();
|
||||
expect(shellFocus.hasPrimaryFocus, isTrue);
|
||||
await tester.pumpAndSettle();
|
||||
});
|
||||
|
||||
testWidgets('the Downloads menu animates only in Material ($mornye)', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
Reference in new issue
Block a user