From 1cf5a9f21575ff391783d8b5bdfbadefa6fe888b Mon Sep 17 00:00:00 2001 From: Deluan Date: Sun, 24 May 2026 21:28:05 -0300 Subject: [PATCH] fix(ui): match canonical name in parseAndReplaceArtists The display string (record.artist/albumArtist) is sourced from mf.Artist/mf.AlbumArtist, which carry the canonical-tag value. Matching on creditedAs failed for Picard-default tagging (ARTIST tag = canonical name, ARTIST_CREDIT = credit) because indexOf could not find the credit inside the canonical display string, silently degrading from inline linkification to bullet-list fallback. Match on artist.name (always equal to displayString slice) and let ALink continue rendering creditedAs || name for visible text. --- ui/src/common/ArtistLinkField.jsx | 6 ++++- ui/src/common/ArtistLinkField.test.jsx | 32 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/ui/src/common/ArtistLinkField.jsx b/ui/src/common/ArtistLinkField.jsx index e9d17801d..055ad18f0 100644 --- a/ui/src/common/ArtistLinkField.jsx +++ b/ui/src/common/ArtistLinkField.jsx @@ -42,7 +42,11 @@ const parseAndReplaceArtists = ( let lastIndex = 0 albumArtists?.forEach((artist) => { - const matchName = artist.creditedAs || artist.name + // Match on the canonical name — that's what appears in displayAlbumArtist + // (sourced from mf.Artist / mf.AlbumArtist, which are set from the canonical + // ARTIST tag at scan time). The ALink itself renders creditedAs || name, + // so the displayed link text still reflects the credit. + const matchName = artist.name const index = displayAlbumArtist.indexOf(matchName, lastIndex) if (index !== -1) { // Add text before the artist name diff --git a/ui/src/common/ArtistLinkField.test.jsx b/ui/src/common/ArtistLinkField.test.jsx index e49873930..a9c850a2c 100644 --- a/ui/src/common/ArtistLinkField.test.jsx +++ b/ui/src/common/ArtistLinkField.test.jsx @@ -286,6 +286,38 @@ describe('ArtistLinkField', () => { const link = screen.getByRole('link') expect(link).not.toHaveAttribute('title') }) + + it('inline-linkifies when displayArtist holds the canonical name (Picard-default tagging)', () => { + // Picard "use standardized artist names" mode: ARTIST tag carries the + // canonical name, ARTIST_CREDIT carries the credit. The display string + // is the canonical name; parseAndReplaceArtists must match on `name` + // (not `creditedAs`) to embed the link inline. The link text itself + // still renders the credit via ALink. + const record = { + artist: 'Planetary Assault Systems', + participants: { + artist: [ + { + id: 'canon-1', + name: 'Planetary Assault Systems', + creditedAs: 'PAS', + }, + ], + }, + } + + render() + + const link = screen.getByRole('link') + // Link text is the credit, tooltip carries canonical + expect(link).toHaveTextContent('PAS') + expect(link).toHaveAttribute('title', 'Planetary Assault Systems') + // The original canonical string should not appear as raw plain text + // (it was replaced by the link) + expect( + screen.queryByText(/^Planetary Assault Systems$/), + ).not.toBeInTheDocument() + }) }) describe('when limiting displayed artists', () => {