fix(web): browser/mouse Forward navigation now works (not only Back)
The popstate listener always called _navGoBack(), but both Back and Forward fire popstate — so Forward was treated as Back and never restored the page you came from. _navGoBack also pushState()'d on every back, which wiped the browser's forward stack entirely. Route all history through the History API: navigate() pushes a state (nsIdx) only on genuine new navigation; popstate now applies whichever entry the browser moved to via _navOnPopState(state.nsIdx), covering Back AND Forward with no pushState in the handler. In-app back buttons / Backspace go through history.back() so there's a single path and the browser stack stays in sync. NowPlaying overlays still close first on a back press. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
3f57e2ae26
commit
79100c5321
2 files changed
+30
-10
No files matched your search
+2
-2
@@ -13,7 +13,7 @@ import {
|
||||
npToggleStar, updateMediaSession, updateNpColorMode, reconcileNativeState, initKeyboardShortcuts,
|
||||
} from './player/player.js';
|
||||
import {
|
||||
navigate, _navGoBack, _navLoad, onHeaderSearch, closeHeaderSearch,
|
||||
navigate, _navGoBack, _navOnPopState, _navLoad, onHeaderSearch, closeHeaderSearch,
|
||||
onGlobalSearch, s_goArtist, s_goAlbum, playerBarGoArtist, playerBarGoAlbum,
|
||||
searchSimilarArtist, searchAndPreview, loadItunesAlbum, closeEventsModal,
|
||||
loadAlbums, loadStarred, loadRandom, filterStarred, filterPlaylist,
|
||||
@@ -299,7 +299,7 @@ window.addEventListener('load', () => {
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('popstate', () => _navGoBack());
|
||||
window.addEventListener('popstate', (e) => _navOnPopState(e.state));
|
||||
document.addEventListener('keydown', e => {
|
||||
if(e.key !== 'Backspace') return;
|
||||
const t = document.activeElement?.tagName;
|
||||
|
||||
Reference in new issue
Block a user