fix(home): Back keeps the question, and the focus finds its card by name

Opening a card left Home, and Back came back to "Doesn't matter" with a
different hero, whose card then dropped out of the Continue rail and moved
the keyboard onto its neighbour. The budget, reroll seed and seen list live
on the history entry now, and a returning list focuses the item by its
name before its place.
This commit is contained in:
2026-09-19 04:51:43 +02:00
parent 6096dd6927
commit 250e3a9f90
5 changed files with 119 additions and 16 deletions
@@ -170,6 +170,30 @@ describe("rememberNavPosition · the list it comes back to (deep-review E11 roun
await waitFor(() => expect(focused()).toBe("a1"));
});
// Home's Continue rail leaves out whatever the hero shows: back from a card, a different hero put a
// card back in front of it, and by its place the focus landed on the neighbour (prod UAT 2026-09-19).
it("finds the item by its name when the rail's contents moved", async () => {
const Rail = ({ titles }: { titles: string[] }) => {
const ref = useRef<HTMLDivElement>(null);
useListNav(ref, { enabled: true });
return (
<div ref={ref} aria-label="Continue watching">
{titles.map((title, i) => (
<div key={title} data-testid={title} data-nav-name={title} {...navItemAttrs(i)}>
{title}
</div>
))}
</div>
);
};
const { unmount } = render(<Rail titles={["Knight Rider", "I Am Mother", "Dawnwalker"]} />);
const stamped = leaveFrom("I Am Mother", 2);
unmount();
landOn(stamped);
render(<Rail titles={["Harry Potter", "Knight Rider", "I Am Mother", "Dawnwalker"]} />);
await waitFor(() => expect(focused()).toBe("I Am Mother"));
});
it("gives up on an unnamed list when the page came back with another number of lists", async () => {
const { unmount } = render(<Page />);
const stamped = leaveFrom("a1", 2);