fix(nav): the dead-page rewrite does not restore a spent focus stamp
It spread the event's snapshot, which still carried the sfNav stamp lib/history's own listener had just taken off the entry, so a later landing there (an overlay closing) refocused a stale item. It now spreads the live entry (test red on the snapshot). Also: format.test's comment named a test image that never runs vitest; it is the gate host's locale.
This commit is contained in:
@@ -200,11 +200,16 @@ export function NavigationProvider({ children }: { children: ReactNode }) {
|
||||
// An entry can name a page this build no longer has (one pushed before a module was removed,
|
||||
// reached by Back after a reload onto the new build); that lands on the feed, not on a crash.
|
||||
// The entry is rewritten to say so: left alone, the address bar would keep naming the dead page
|
||||
// and a click on Feed would be a no-op (setPage's same-page guard).
|
||||
// and a click on Feed would be a no-op (setPage's same-page guard). It spreads the LIVE entry,
|
||||
// not `e.state`: lib/history's listener ran first and already took the spent `sfNav` off it.
|
||||
const sf: unknown = e.state?.sfPage;
|
||||
const p: Page = typeof sf === "string" && isPage(sf) ? sf : "feed";
|
||||
if (typeof sf === "string" && sf !== p)
|
||||
window.history.replaceState({ ...e.state, sfPage: p }, "", urlWithParams({ page: null }));
|
||||
window.history.replaceState(
|
||||
{ ...window.history.state, sfPage: p },
|
||||
"",
|
||||
urlWithParams({ page: null }),
|
||||
);
|
||||
setPageState(p);
|
||||
setAccountRaw(PAGE_KEY, p);
|
||||
// The YouTube-search sub-view and the channel page ride in history.state, so Back/Forward
|
||||
|
||||
Reference in New Issue
Block a user