fix(ui): Enter on a selectable title opens it even with its words selected

endsTextSelection takes the click event and exempts a keyboard click (detail 0): Enter / Space
ends no selection, so a title selected and then tabbed to opened nothing. All three callers
(FocusSafeButton, the Plex caption, the video card title) go through it.
This commit is contained in:
2026-09-27 14:55:50 +02:00
parent 52c15adaf2
commit 0b1d905866
7 changed files with 34 additions and 14 deletions
+7 -2
View File
@@ -4,8 +4,13 @@
// A plain click collapses any selection on mousedown, so a non-empty selection that touches the
// element at click time can only be the one this gesture just made.
/** True when the page's selection is non-empty and starts or ends inside `el`. */
export function endsTextSelection(el: Element): boolean {
/** True when this click ended a selection: the page's selection is non-empty and starts or ends
* inside the clicked element. Takes the EVENT, not the element, because a keyboard click (Enter /
* Space, `detail` 0) ends no selection — it has no pointer — so a title whose words are still
* selected must open on Enter (E28 review H2). */
export function endsTextSelection(e: { currentTarget: Element; detail: number }): boolean {
if (e.detail === 0) return false;
const el = e.currentTarget;
const sel = typeof window === "undefined" ? null : window.getSelection();
if (!sel || sel.isCollapsed || !sel.toString().trim()) return false;
return (