fix(player): keep Delete and Home editing text in player sheets

Bare Backspace and Home are player navigation keys, but they are also
caret editing keys. The player screen's Focus wraps its OverlaySheetHost,
so it saw them before the subtitle-search field could act: the press was
consumed on key-down, DefaultTextEditingShortcuts never turned it into a
deletion, and the back pipeline hid the chrome and then left the player.

A focused text editor now takes both keys back, but only for physical
keyboard presses — a synthesized dpad/gamepad press has no caret, and
browserHome has no editing role at all.

The screen also resolved its overlay-sheet controller from the State's
own context, which sits above the host it was querying, so the lookup
always returned null and Back skipped the sheet stage entirely. Resolve
it from a context below the host instead, matching NowPlayingScreen.

close #1741
This commit is contained in:
edde746
2026-08-02 07:37:12 +02:00
parent 2a7e5f4f9c
commit bac2a0d201
5 changed files with 421 additions and 3 deletions
+10 -1
View File
@@ -466,6 +466,14 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
// key events never escape the video player route.
late final FocusNode _screenFocusNode;
/// Key for a context below this screen's own [OverlaySheetHost]. The State's
/// context sits ABOVE the host, so resolving the controller with `context`
/// always misses it and the screen would walk its back pipeline (hide chrome,
/// then exit the player) while a sheet is still open (#1741).
final GlobalKey _overlayChildKey = GlobalKey();
BuildContext get _sheetContext => _overlayChildKey.currentContext ?? context;
// VLC-style in-player toast controller (rate changes, backend switch, etc.).
final PlayerToastController _toastController = PlayerToastController();
bool _reclaimingFocus = false;
@@ -1454,7 +1462,7 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
void _handleScreenPlayerNavigation(PlayerNavigationKey navigationKey) {
if (navigationKey != PlayerNavigationKey.home) {
final sheetController = OverlaySheetController.maybeOf(context);
final sheetController = OverlaySheetController.maybeOf(_sheetContext);
if (sheetController?.isOpen ?? false) {
sheetController!.pop();
return;
@@ -1998,6 +2006,7 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
_handleScreenPlayerNavigation(PlayerNavigationKey.back);
},
child: Builder(
key: _overlayChildKey,
builder: (sheetContext) => _isPlayerInitialized && player != null
? _buildVideoPlayer(sheetContext)
: (_playerInitializationError != null