fix(nav): a sub-view step closes the overlays standing over it first
Leaving the Plex player while one of its layers was up (the info panel when the film ended, the countdown under the back arrow) landed as a user Back: the overlay listener spent it closing the top layer and the player stayed. useHistorySubview's open/back now go through closeOverlaysThenNavigate, like setPage. The RECLOSE comment no longer cites the shared Plex entry.
This commit is contained in:
@@ -7,8 +7,8 @@
|
||||
// an overlay's programmatic history.back()) restores the sub-view from the URL instead of collapsing
|
||||
// it to root. The overlay/back-ladder half of history.ts is covered in history.dom.test.ts.
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
|
||||
import { renderHook, act } from "@testing-library/react";
|
||||
import { useHistorySubview, type SubviewUrl } from "./history";
|
||||
import { renderHook, act, waitFor } from "@testing-library/react";
|
||||
import { useBackToClose, useHistorySubview, type SubviewUrl } from "./history";
|
||||
|
||||
// A minimal string-view mirror: "root" is the un-mirrored root (encode → null), anything else mirrors
|
||||
// verbatim to ?v=<view>. decode rejects the empty string (→ null, i.e. not a valid sub-view).
|
||||
@@ -207,6 +207,31 @@ describe("useHistorySubview back", () => {
|
||||
expect(back).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
// A sub-view left while an overlay of its own is still up — the Plex player's stats readout, a
|
||||
// panel, the shortcuts sheet: the step back used to land as a USER Back, so the overlay listener
|
||||
// spent it closing the top overlay and the sub-view stayed where it was.
|
||||
it("closes the overlays standing over it first, then steps back out of the sub-view", async () => {
|
||||
const { result } = renderHook(() => useHistorySubview("root", url));
|
||||
act(() => result.current.open("player"));
|
||||
const closed = vi.fn();
|
||||
const holder: { unmount?: () => void } = {};
|
||||
const layer = renderHook(() =>
|
||||
useBackToClose(() => {
|
||||
closed();
|
||||
holder.unmount?.();
|
||||
}),
|
||||
);
|
||||
holder.unmount = layer.unmount;
|
||||
await act(async () => {
|
||||
await Promise.resolve();
|
||||
});
|
||||
expect(window.history.state?._ov).toBeDefined();
|
||||
act(() => result.current.back());
|
||||
await waitFor(() => expect(result.current.view).toBe("root"));
|
||||
expect(closed).toHaveBeenCalledTimes(1);
|
||||
expect(window.history.state?._ov).toBeUndefined();
|
||||
});
|
||||
|
||||
it("returns to the root in place when the entry below is another document's", () => {
|
||||
const { result } = renderHook(() => useHistorySubview("root", url));
|
||||
act(() => result.current.open("a"));
|
||||
|
||||
Reference in New Issue
Block a user