fix(player): the shut panel keeps the dialog's name; Tab onto a cut link opens the text

With the side panel shut the title heading was gone, and the dialog it named
went unnamed: the strip carries an sr-only copy. A link below a clamp's cut
stayed tabbable out of sight; reaching it now opens the text, measured from the
text's top since focus scrolls the clamped box. DESIGN describes the modal as
built, with log rows for its chrome and the wheel rule.
This commit is contained in:
2026-10-09 22:01:27 +02:00
parent 76738f8ea9
commit 5572499b56
5 changed files with 175 additions and 117 deletions
+14 -7
View File
@@ -400,8 +400,8 @@ pick a density step; it never changes the anatomy or loses an action. [Nielsen #
`mediaTitleClass`, `mediaPictureBox`). `mediaTitleClass`, `mediaPictureBox`).
- **Play only where the click plays.** The hover layer dims the picture and shows `MediaPlayGlyph`, the - **Play only where the click plays.** The hover layer dims the picture and shows `MediaPlayGlyph`, the
one round media Play (the button family's `media` variant), only on a card whose click starts one round media Play (the button family's `media` variant), only on a card whose click starts
playback. Every Plex picture plays, a show too: the episode in progress (Continue + Restart), else the playback. Every Plex picture plays, a show too: the episode in progress (Continue + Restart, offered only
first unwatched, else the first, which the click asks the server for (`/show/{id}/next`); its title when an episode holds a resume point), else the first unwatched, else the first, which the click asks the server for (`/show/{id}/next`); its title
and an ⓘ open the show's page, and one with no episodes opens there. The hover row (watched, save or and an ⓘ open the show's page, and one with no episodes opens there. The hover row (watched, save or
add, "…") docks at the picture's bottom-right; the length badge steps aside while it shows. add, "…") docks at the picture's bottom-right; the length badge steps aside while it shows.
- **Density.** A grid card: a two-line title and the full meta (Plex: year · ★ score; a video: the - **Density.** A grid card: a two-line title and the full meta (Plex: year · ★ score; a video: the
@@ -536,9 +536,14 @@ of a full-width panel and nothing on the right.
applies to the item the player opened on (`fromStart`); every item it moves on to resumes. A library applies to the item the player opened on (`fromStart`); every item it moves on to resumes. A library
row is not a card and keeps its one play button: started, that button continues, its "…" has Continue + row is not a card and keeps its one play button: started, that button continues, its "…" has Continue +
"Play from the beginning", and its picture carries the cards' progress bar. "Play from the beginning", and its picture carries the cards' progress bar.
- **The YouTube modal:** its chrome uses the `Button` rungs (44 on touch), the side arrows stay inside the - **The YouTube modal:** its chrome uses the `Button` rungs (44 on touch); Previous / Next live in the panel
screen, and the description opens from an ⓘ button, because a hover popover never opens on a tap (measured (its transport row, or the shut panel's strip) and on Shift+← / →, with no strips beside the card. Close is
live). [WCAG 1.4.13] an icon in the card's top-right corner. Wide, the panel shows the description outright, clamped to three
lines with a More (`ClampedText`; a Tab onto a link below the cut opens it), and collapses to a 2.75rem
strip of close, expand and Previous / Next, kept shut as the queue steps on and open again on a new
open. Stacked, the description opens from an ⓘ, because a hover popover never opens on a tap (measured
live). The wheel: over the video it sets the volume; over a panel with something to scroll it scrolls
only, never the volume, even at its end; over one with nothing to scroll it sets the volume. [WCAG 1.4.13]
## Dialogs — _Decided_ (C4, built in S3f) ## Dialogs — _Decided_ (C4, built in S3f)
@@ -615,7 +620,7 @@ of a full-width panel and nothing on the right.
## Decision log ## Decision log
| Date | Decision | Chosen | Over | Why | | Date | Decision | Chosen | Over | Why |
| ---------- | ------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ---------- | ------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 2026-09-24 | Floating button | Back to top: a round 48 glass FAB; "round" = floats over something (media or the page) | A Material 3 rounded square; a labelled pill; the old 64 circle | The common web convention for back to top; round tells it apart from every toolbar button; 64 was oversized | | 2026-09-24 | Floating button | Back to top: a round 48 glass FAB; "round" = floats over something (media or the page) | A Material 3 rounded square; a labelled pill; the old 64 circle | The common web convention for back to top; round tells it apart from every toolbar button; 64 was oversized |
| 2026-09-24 | Device contract | Tablet portrait + landscape and up; phones out | A 1024px floor with a "too small" message | Portrait tablet use is real, and the app already renders at 820 portrait | | 2026-09-24 | Device contract | Tablet portrait + landscape and up; phones out | A 1024px floor with a "too small" message | Portrait tablet use is real, and the app already renders at 820 portrait |
| 2026-09-24 | Card actions on touch | Fewer visible, the rest in a "…" menu | 44px buttons that no longer fit the card | Six 44px targets need more width than a card has | | 2026-09-24 | Card actions on touch | Fewer visible, the rest in a "…" menu | 44px buttons that no longer fit the card | Six 44px targets need more width than a card has |
@@ -721,4 +726,6 @@ of a full-width panel and nothing on the right.
| 2026-10-08 | Plex subtitles and the control bar | The player draws the cues itself; while the bar shows they rise above it (200 ms), then settle back | The browser's own cues, moved by `line` | On an iPad the bar covered the text; a native cue cannot be animated or measured, and our layer behaves the same on every engine | | 2026-10-08 | Plex subtitles and the control bar | The player draws the cues itself; while the bar shows they rise above it (200 ms), then settle back | The browser's own cues, moved by `line` | On an iPad the bar covered the text; a native cue cannot be animated or measured, and our layer behaves the same on every engine |
| 2026-10-08 | Hover on a button over a picture | The `media` variant's hover is a 2px accent ring over a darker body (Plex + YT cards, rail arrows; option B) | An accent fill (reads as "selected"); a white wash (weak on a bright poster) | The 60 → 75% black step was invisible, and over a card a rail arrow could not be told from the card's own Play under it | | 2026-10-08 | Hover on a button over a picture | The `media` variant's hover is a 2px accent ring over a darker body (Plex + YT cards, rail arrows; option B) | An accent fill (reads as "selected"); a white wash (weak on a bright poster) | The 60 → 75% black step was invisible, and over a card a rail arrow could not be told from the card's own Play under it |
| 2026-10-08 | Plex "Add to collection" | A movie or show card's menu row opens a panel beside the card: its library's manual collections tick in place, a name + Enter creates one with the title in it (admin; option A) | An Add submenu with a "New…" dialog; the per-title editor modal from the menu | A collection took a trip to the Collections page, a name, a title search, then a second search per title; the panel is the video card's "Add to playlist" | | 2026-10-08 | Plex "Add to collection" | A movie or show card's menu row opens a panel beside the card: its library's manual collections tick in place, a name + Enter creates one with the title in it (admin; option A) | An Add submenu with a "New…" dialog; the per-title editor modal from the menu | A collection took a trip to the Collections page, a name, a title search, then a second search per title; the panel is the video card's "Add to playlist" |
| 2026-10-09 | A Plex show card plays | Its picture plays the show's next episode everywhere (in progress → Continue + Restart, else the first unwatched, else S1·E1), resolved on the click; the preview names it once up; title and ⓘ open the show (option A + hover ask) | The picture opens the show page (as before); every card carrying `next` | A show card on Discover had no Play while Home's had one; carrying `next` costs a grid page up to 180 queries for the few cards anyone plays | | 2026-10-08 | YouTube modal chrome | No prev/next strips beside the card; Close an icon in the card's corner; the description clamped to three lines + More; the panel shuts to a 2.75rem strip of close, expand, prev/next (option D1) | Keep the strips; a "Close" text button; the full description in a scroller; a panel that hides outright | The strips cost the video 7rem of width for a second copy of the panel's buttons; a long description pushed the channel and the actions out of sight; a hidden panel left no way to step the queue without the keyboard |
| 2026-10-08 | The wheel over the YouTube modal | Over the video: volume. Over a panel with something to scroll: scroll only, never volume, not even at its end. Over a panel with nothing to scroll: volume (owner) | Volume everywhere; a scroll that hands over to the volume at its end | Reading a long description turned the volume down once it hit the end |
| 2026-10-09 | A Plex show card plays | Its picture plays the show's next episode everywhere (an episode with a resume point → Continue + Restart, else the first unwatched, else S1·E1), resolved on the click; the preview names it once up; title and ⓘ open the show (option A + hover ask) | The picture opens the show page (as before); every card carrying `next` | A show card on Discover had no Play while Home's had one; carrying `next` costs a grid page up to 180 queries for the few cards anyone plays |
@@ -629,8 +629,11 @@ describe("PlayerModal — the side panel on a wide window", () => {
expect(row().style.maxWidth).toBe("calc((100dvh - 3rem - 0px) * 16 / 9 + 2.75rem)"); expect(row().style.maxWidth).toBe("calc((100dvh - 3rem - 0px) * 16 / 9 + 2.75rem)");
// The strip keeps the way out and the stepping. // The strip keeps the way out and the stepping.
expect(within(strip).getByTestId("player-close")).toBeTruthy(); expect(within(strip).getByTestId("player-close")).toBeTruthy();
// The dialog keeps its name with the title out of sight: it is named by that heading's id.
expect(screen.getByRole("dialog", { name: "Video A" })).toBeTruthy();
fireEvent.click(within(strip).getByRole("button", { name: "player.next" })); fireEvent.click(within(strip).getByRole("button", { name: "player.next" }));
expect(screen.getByTestId("player-strip")).toBeTruthy(); // still shut on the next video expect(screen.getByTestId("player-strip")).toBeTruthy(); // still shut on the next video
expect(screen.getByRole("dialog", { name: "Video B" })).toBeTruthy();
fireEvent.click( fireEvent.click(
within(screen.getByTestId("player-strip")).getByRole("button", { within(screen.getByTestId("player-strip")).getByRole("button", {
name: "player.expandPanel", name: "player.expandPanel",
+7 -1
View File
@@ -324,6 +324,8 @@ export default function PlayerModal({
const navigated = currentVideoId !== active.id; const navigated = currentVideoId !== active.id;
// Title/author of a navigated-to video, read from the player (free, no API call). // Title/author of a navigated-to video, read from the player (free, no API call).
const [liveData, setLiveData] = useState<{ title?: string; author?: string } | null>(null); const [liveData, setLiveData] = useState<{ title?: string; author?: string } | null>(null);
// What is playing, by name: the panel's title, and the dialog's name (`titleId`) in either layout.
const heading = navigated ? (liveData?.title ?? t("player.loading")) : active.title;
// IFrame Player API error code, when the current video can't play in the embed (e.g. an // IFrame Player API error code, when the current video can't play in the embed (e.g. an
// auto-generated Topic "Art Track" with embedding disabled → 101/150, or removed/private → // auto-generated Topic "Art Track" with embedding disabled → 101/150, or removed/private →
// 100). We overlay a friendly message + "Open on YouTube" instead of YouTube's bare error. // 100). We overlay a friendly message + "Open on YouTube" instead of YouTube's bare error.
@@ -919,6 +921,10 @@ export default function PlayerModal({
data-testid="player-strip" data-testid="player-strip"
className="absolute inset-0 flex flex-col items-center gap-1 py-2" className="absolute inset-0 flex flex-col items-center gap-1 py-2"
> >
{/* The dialog is named by this heading's id: the panel's own one is not rendered. */}
<h2 id={titleId} className="sr-only">
{heading}
</h2>
{closeButton} {closeButton}
<IconButton <IconButton
ref={panelToggleRef} ref={panelToggleRef}
@@ -995,7 +1001,7 @@ export default function PlayerModal({
right (wide, it heads the panel). */} right (wide, it heads the panel). */}
<div className="flex items-start gap-3"> <div className="flex items-start gap-3">
<h2 id={titleId} className="min-w-0 flex-1 text-lg font-semibold leading-snug"> <h2 id={titleId} className="min-w-0 flex-1 text-lg font-semibold leading-snug">
{navigated ? (liveData?.title ?? t("player.loading")) : active.title} {heading}
</h2> </h2>
{!wide && ( {!wide && (
<IconButton <IconButton
@@ -45,6 +45,34 @@ describe("ClampedText", () => {
} }
}); });
it("opens when focus reaches a link the cut hides, and not for one in sight", () => {
const tall = vi.spyOn(HTMLElement.prototype, "scrollHeight", "get").mockReturnValue(400);
const box = vi.spyOn(HTMLElement.prototype, "clientHeight", "get").mockReturnValue(60);
const rect = (top: number, bottom: number) => ({ top, bottom }) as DOMRect;
try {
render(
<ClampedText text="t" lines={3} moreLabel="More" lessLabel="Less">
<a href="#a">seen</a>
<a href="#b">cut</a>
</ClampedText>,
);
const clamp = screen.getByText("seen").parentElement!;
vi.spyOn(clamp, "getBoundingClientRect").mockReturnValue(rect(100, 160));
vi.spyOn(screen.getByText("seen"), "getBoundingClientRect").mockReturnValue(rect(100, 120));
act(() => screen.getByText("seen").focus());
expect(screen.getByText("More")).toBeTruthy();
// A Tab onto a link below the cut. The browser scrolls the clamped box to show it (measured in
// Chrome: 45 px), so on screen the link sits inside the box: only the text's own top tells.
clamp.scrollTop = 240;
vi.spyOn(screen.getByText("cut"), "getBoundingClientRect").mockReturnValue(rect(130, 150));
act(() => screen.getByText("cut").focus());
expect(screen.getByText("Less").getAttribute("aria-expanded")).toBe("true");
} finally {
tall.mockRestore();
box.mockRestore();
}
});
it("starts another text collapsed: a reused view opening the next item", () => { it("starts another text collapsed: a reused view opening the next item", () => {
const tall = vi.spyOn(HTMLElement.prototype, "scrollHeight", "get").mockReturnValue(400); const tall = vi.spyOn(HTMLElement.prototype, "scrollHeight", "get").mockReturnValue(400);
const box = vi.spyOn(HTMLElement.prototype, "clientHeight", "get").mockReturnValue(60); const box = vi.spyOn(HTMLElement.prototype, "clientHeight", "get").mockReturnValue(60);
+17 -3
View File
@@ -1,4 +1,4 @@
import { useLayoutEffect, useRef, useState, type ReactNode } from "react"; import { useLayoutEffect, useRef, useState, type FocusEvent, type ReactNode } from "react";
import { Button } from "./Button"; import { Button } from "./Button";
// Static class names, so Tailwind sees them. // Static class names, so Tailwind sees them.
@@ -9,7 +9,9 @@ const CLAMP = { 3: "line-clamp-3", 5: "line-clamp-5", 8: "line-clamp-8" } as con
* resize: the window and the text-size slider both move where the cut falls. Another text starts * resize: the window and the text-size slider both move where the cut falls. Another text starts
* collapsed: a view reused for the next item (a show page opening another show) must not open its * collapsed: a view reused for the next item (a show page opening another show) must not open its
* text already expanded. `children` draws the text in a richer form (a description's links and * text already expanded. `children` draws the text in a richer form (a description's links and
* timestamps); `text` still names it, so another text is still another text. */ * timestamps); `text` still names it, so another text is still another text. A link the cut hides
* stays in the tab order (it is still text), so reaching it opens the text: focus never sits on
* something out of sight. */
export function ClampedText({ export function ClampedText({
text, text,
lines, lines,
@@ -45,9 +47,21 @@ export function ClampedText({
ro.observe(el); ro.observe(el);
return () => ro.disconnect(); return () => ro.disconnect();
}, [text, expanded]); }, [text, expanded]);
// Measured from the text's top, not against the box on screen: focus scrolls the clamped box itself
// to bring the link into view (overflow:hidden still scrolls), so on screen it looked "in sight".
const revealFocused = (e: FocusEvent<HTMLDivElement>) => {
const box = e.currentTarget;
if (expanded || e.target === box) return;
const top = box.getBoundingClientRect().top - box.scrollTop;
if (e.target.getBoundingClientRect().bottom - top > box.clientHeight + 1) setExpanded(true);
};
return ( return (
<div className={className}> <div className={className}>
<div ref={ref} className={`${textClassName} ${expanded ? "" : CLAMP[lines]}`}> <div
ref={ref}
className={`${textClassName} ${expanded ? "" : CLAMP[lines]}`}
onFocus={revealFocused}
>
{children ?? text} {children ?? text}
</div> </div>
{(clipped || expanded) && ( {(clipped || expanded) && (