Fix stale _artistDetailGoingBack flag when back lands on non-artist page

If history.back() navigated away from artist-detail entirely (e.g. to
library), _artistDetailGoingBack stayed true. The next forward artist
navigation would then pop the label stack instead of pushing, causing
the back-button label to show plain Back instead of the correct page.

Guard the pop with currentPage === artist-detail; clear the flag
unconditionally in the else branch.
This commit is contained in:
Broque Thomas 2026-05-19 12:55:38 -07:00
parent e7ba5408aa
commit 1575ba4684

View file

@ -818,10 +818,13 @@ function navigateToArtistDetail(artistId, artistName, sourceOverride = null, opt
console.log(`🎵 Navigating to artist detail: ${artistName} (ID: ${artistId}${sourceOverride ? `, source: ${sourceOverride}` : ''})`);
// Maintain the label stack. Back navigations pop; forward navigations push.
if (_artistDetailGoingBack) {
// Only treat the flag as a back-nav signal when we're still on artist-detail —
// if history.back() landed on a non-artist page first, the flag is stale.
if (_artistDetailGoingBack && currentPage === 'artist-detail') {
_artistDetailLabelStack.pop();
_artistDetailGoingBack = false;
} else {
_artistDetailGoingBack = false; // clear any stale flag
if (currentPage !== 'artist-detail') {
_artistDetailLabelStack = []; // fresh chain from a non-artist page
}