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:
@@ -325,7 +325,22 @@ PlayerBackDisposition resolvePlayerBackDisposition({
|
||||
return controlsVisible ? PlayerBackDisposition.hideControls : PlayerBackDisposition.exitPlayer;
|
||||
}
|
||||
|
||||
PlayerNavigationKey classifyPlayerNavigationKey(KeyEvent event, {required bool isAppleTV, bool? hasModifiers}) {
|
||||
/// Maps a key event to the player-level navigation stage it should drive.
|
||||
///
|
||||
/// [textEditingActive] defaults to [isTextEditingFocused]; inject it in tests.
|
||||
/// Bare Backspace and Home double as player navigation *and* as caret editing
|
||||
/// keys, so a focused text editor takes them back — otherwise typing in a
|
||||
/// player sheet (subtitle search) walks the back pipeline out of the player
|
||||
/// instead of correcting a character (#1741). Only physical-keyboard presses
|
||||
/// are surrendered: a synthesized dpad/gamepad/companion press has no caret,
|
||||
/// and [LogicalKeyboardKey.browserHome] is a dedicated navigation key with no
|
||||
/// editing role at all.
|
||||
PlayerNavigationKey classifyPlayerNavigationKey(
|
||||
KeyEvent event, {
|
||||
required bool isAppleTV,
|
||||
bool? hasModifiers,
|
||||
bool? textEditingActive,
|
||||
}) {
|
||||
final key = event.logicalKey;
|
||||
if (key == LogicalKeyboardKey.escape) {
|
||||
return event.isPhysicalKeyboardEvent && !isAppleTV ? PlayerNavigationKey.physicalEscape : PlayerNavigationKey.back;
|
||||
@@ -338,10 +353,14 @@ PlayerNavigationKey classifyPlayerNavigationKey(KeyEvent event, {required bool i
|
||||
HardwareKeyboard.instance.isControlPressed ||
|
||||
HardwareKeyboard.instance.isAltPressed ||
|
||||
HardwareKeyboard.instance.isMetaPressed);
|
||||
// Resolved lazily: only the two editing keys below pay for the focus lookup.
|
||||
bool textEditorOwnsKey() => event.isPhysicalKeyboardEvent && (textEditingActive ?? isTextEditingFocused());
|
||||
|
||||
if (key == LogicalKeyboardKey.backspace && event.isPhysicalKeyboardEvent && !modifiersPressed) {
|
||||
return PlayerNavigationKey.back;
|
||||
return textEditorOwnsKey() ? PlayerNavigationKey.none : PlayerNavigationKey.back;
|
||||
}
|
||||
if ((key == LogicalKeyboardKey.home || key == LogicalKeyboardKey.browserHome) && !modifiersPressed) {
|
||||
if (key == LogicalKeyboardKey.home && textEditorOwnsKey()) return PlayerNavigationKey.none;
|
||||
return PlayerNavigationKey.home;
|
||||
}
|
||||
return PlayerNavigationKey.none;
|
||||
|
||||
Reference in New Issue
Block a user