Page-aware click on similar-artist bubbles
The bubble click handler hardcoded selectArtistForDetail (the inline Artists page navigator). On the standalone /artist-detail page it fired but couldn't actually navigate anywhere — the page just re-rendered the similar-artists section for the same artist instead of moving to the clicked artist. Now: detect whether the standalone page is active. If yes, navigateToArtistDetail(id, name, source). Otherwise fall back to selectArtistForDetail for the inline page (unchanged behaviour there). Both surfaces work correctly without the caller having to know which page they're on.
This commit is contained in:
parent
6a76405444
commit
5219780c01
1 changed files with 12 additions and 6 deletions
|
|
@ -3110,14 +3110,20 @@ function createSimilarArtistBubble(artist) {
|
|||
bubble.appendChild(genres);
|
||||
}
|
||||
|
||||
// Add click handler to navigate to artist detail page
|
||||
// Add click handler — page-aware destination. From the standalone artist-
|
||||
// detail page, navigate to the standalone route. From the inline Artists
|
||||
// page, swap the inline view via selectArtistForDetail.
|
||||
bubble.addEventListener('click', () => {
|
||||
console.log(`🎵 Clicked similar artist: ${artist.name} (ID: ${artist.id})`);
|
||||
// Navigate to this artist's detail page (same as clicking from search results)
|
||||
selectArtistForDetail(
|
||||
artist,
|
||||
artist.source ? { source: artist.source, plugin: artist.plugin } : {}
|
||||
);
|
||||
const onStandalone = !!document.querySelector('#artist-detail-page.active');
|
||||
if (onStandalone && typeof navigateToArtistDetail === 'function') {
|
||||
navigateToArtistDetail(artist.id, artist.name, artist.source || null);
|
||||
} else if (typeof selectArtistForDetail === 'function') {
|
||||
selectArtistForDetail(
|
||||
artist,
|
||||
artist.source ? { source: artist.source, plugin: artist.plugin } : {}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
return bubble;
|
||||
|
|
|
|||
Loading…
Reference in a new issue