fix(design): a row's "…" closes its own menu when its row object is rebuilt (E28 S3e2)
The "…" told its own menu from another row's by payload identity. The Plex playlist page builds each row's menu target afresh on every render, so a second press on the same "…" reopened the menu instead of closing it. useContextMenu takes an optional `keyOf`, and the page keys its targets by the row key.
This commit is contained in:
@@ -69,11 +69,12 @@ type Layout = "accordion" | "tree";
|
||||
type Season = { key: string; number: number | null; items: PlexCard[] };
|
||||
type ShowBlock = Extract<Block, { kind: "show" }>;
|
||||
/** What a row's menu acts on. `key` is the row's identity across renders (the objects are rebuilt
|
||||
* on every one), so "is THIS row's menu the open one" compares keys. */
|
||||
* on every one), so "is THIS row's menu the open one" — and the "…" closing its own — compare keys. */
|
||||
type MenuTarget =
|
||||
| { kind: "item"; key: string; item: PlexCard }
|
||||
| { kind: "show"; key: string; block: ShowBlock }
|
||||
| { kind: "season"; key: string; block: ShowBlock; season: Season };
|
||||
const targetKey = (t: MenuTarget) => t.key;
|
||||
type Block =
|
||||
| { kind: "movie"; id: string; item: PlexCard }
|
||||
| {
|
||||
@@ -535,7 +536,8 @@ export default function PlexPlaylistView({
|
||||
}
|
||||
|
||||
// --- The rows' ONE menu (E28 C1) -------------------------------------------------------------
|
||||
const rowMenu = useContextMenu<MenuTarget>();
|
||||
// Keyed: a row builds its target afresh each render, and its "…" must close the menu it opened.
|
||||
const rowMenu = useContextMenu<MenuTarget>({ keyOf: targetKey });
|
||||
const copy = useCopyItems();
|
||||
const seasonLabel = useSeasonLabel();
|
||||
const titleActions = usePlexCardActions(
|
||||
|
||||
Reference in New Issue
Block a user