mirror of
https://github.com/navidrome/navidrome.git
synced 2026-06-02 07:01:36 +00:00
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.
This commit is contained in:
parent
86cb5fee93
commit
1cf5a9f215
@ -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
|
||||
|
||||
@ -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(<ArtistLinkField record={record} source="artist" />)
|
||||
|
||||
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', () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user