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:
@@ -123,6 +123,23 @@ KeyEventResult handleOneShotSelect(KeyEvent event, VoidCallback onActivate) {
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
|
||||
/// Whether the primary focus currently belongs to an active text editor.
|
||||
///
|
||||
/// Ancestor key handlers use this to stay off keys a focused field owns.
|
||||
/// Flutter dispatches a key event from the focused node upwards, and the
|
||||
/// editing shortcuts that turn Backspace into a deletion live in
|
||||
/// [DefaultTextEditingShortcuts] at the very top of the app — *above* any
|
||||
/// screen. An ancestor that claims Backspace as "back" therefore both steals
|
||||
/// the navigation and stops the character from ever being deleted (#1741).
|
||||
///
|
||||
/// [EditableText] builds its [Focus] internally, so the focused node's context
|
||||
/// resolves to the owning [EditableTextState].
|
||||
bool isTextEditingFocused() {
|
||||
final context = FocusManager.instance.primaryFocus?.context;
|
||||
if (context == null) return false;
|
||||
return context.findAncestorStateOfType<EditableTextState>() != null;
|
||||
}
|
||||
|
||||
/// Expands a UTF-16 [range] to whole extended grapheme clusters in [text].
|
||||
///
|
||||
/// Flutter selections use UTF-16 code-unit offsets. Custom editors must pass a
|
||||
|
||||
Reference in New Issue
Block a user