Skip to content

Commit ee3c889

Browse files
Fix mobile artist badge centering (#14495)
## Summary - Center the actual rendered mobile artist row, including badges, by removing the hidden badge spacer row - Keep badges next to each artist name in multi-artist rows - Add a test guard so each artist badge set only renders once ## Verification - npm run typecheck -w @audius/mobile -- --noEmit - npm run lint -w @audius/mobile -- src/components/user-link/TrackArtists.tsx src/components/user-link/TrackArtists.test.tsx src/screens/track-screen/TrackScreenDetailsTile.tsx - cd packages/mobile && ../../node_modules/.bin/jest src/components/user-link/TrackArtists.test.tsx --runInBand
1 parent a1e8079 commit ee3c889

2 files changed

Lines changed: 4 additions & 41 deletions

File tree

packages/mobile/src/components/user-link/TrackArtists.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,7 @@ describe('TrackArtists', () => {
7676
expect(within(ownerGroup).getByText('badges:1')).toBeOnTheScreen()
7777
expect(within(collaboratorGroup).getByText('2:dj g8r')).toBeOnTheScreen()
7878
expect(within(collaboratorGroup).getByText('badges:2')).toBeOnTheScreen()
79+
expect(screen.getAllByText('badges:1')).toHaveLength(1)
80+
expect(screen.getAllByText('badges:2')).toHaveLength(1)
7981
})
8082
})

packages/mobile/src/components/user-link/TrackArtists.tsx

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,6 @@ import { UserLink } from './UserLink'
1414

1515
type Collaborator = { user_id: ID }
1616

17-
type ArtistBadgesProps = ComponentProps<typeof UserBadges> & {
18-
isSpacer?: boolean
19-
}
20-
21-
const ArtistBadges = ({ isSpacer, ...props }: ArtistBadgesProps) => (
22-
<Flex
23-
row
24-
alignItems='center'
25-
gap='xs'
26-
pointerEvents={isSpacer ? 'none' : undefined}
27-
accessibilityElementsHidden={isSpacer}
28-
importantForAccessibility={isSpacer ? 'no-hide-descendants' : undefined}
29-
style={isSpacer ? styles.badgeSpacer : undefined}
30-
>
31-
<Flex style={styles.badgeGapAnchor} />
32-
<UserBadges {...props} />
33-
</Flex>
34-
)
35-
3617
type CollaboratorLinksProps = Omit<
3718
ComponentProps<typeof UserLink>,
3819
'userId'
@@ -117,24 +98,13 @@ export const TrackArtists = ({
11798
w='100%'
11899
style={styles.artistLine}
119100
>
120-
<Flex row alignItems='center' style={styles.badgeSpacerRow}>
121-
{artists.map((artist) => (
122-
<ArtistBadges
123-
key={artist.userId}
124-
userId={artist.userId}
125-
badgeSize={badgeSize}
126-
mint={artist.userId === userId ? mint : undefined}
127-
hideFanClubBadge={hideFanClubBadge}
128-
isSpacer
129-
/>
130-
))}
131-
</Flex>
132101
{artists.map((artist, index) => (
133102
<Fragment key={artist.userId}>
134103
{index > 0 ? <Text color='subdued'>, </Text> : null}
135104
<Flex
136105
row
137106
alignItems='center'
107+
gap='xs'
138108
style={styles.artistGroup}
139109
testID={`track-artist-${artist.userId}`}
140110
>
@@ -146,7 +116,7 @@ export const TrackArtists = ({
146116
>
147117
{artist.name}
148118
</TextLink>
149-
<ArtistBadges
119+
<UserBadges
150120
userId={artist.userId}
151121
badgeSize={badgeSize}
152122
mint={artist.userId === userId ? mint : undefined}
@@ -169,15 +139,6 @@ const styles = StyleSheet.create({
169139
minWidth: 0,
170140
overflow: 'hidden'
171141
},
172-
badgeSpacerRow: {
173-
flexShrink: 0
174-
},
175-
badgeSpacer: {
176-
opacity: 0
177-
},
178-
badgeGapAnchor: {
179-
width: 0
180-
},
181142
artistGroup: {
182143
flexShrink: 1,
183144
minWidth: 0

0 commit comments

Comments
 (0)