Skip to content

Commit 967bc4e

Browse files
authored
fix: use translated series title in series indicator and fix cookie b… (#115)
* fix: use translated series title in series indicator and fix cookie banner safe area * test: update MainLayout snapshot for cookie banner safe area padding * fix: use distinct initial keys for image, embed, and gpx modals Three sibling modals all started with key=0, triggering React duplicate key warnings.
1 parent 6061917 commit 967bc4e

5 files changed

Lines changed: 38 additions & 4 deletions

File tree

apps/web/app/admin/(auth)/posts/components/PostEditor/PostEditor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ export function PostEditor({
247247
const [isEmbedInsertModalOpen, setIsEmbedInsertModalOpen] = useState(false)
248248
const [isGpxModalOpen, setIsGpxModalOpen] = useState(false)
249249
const [imageModalKey, setImageModalKey] = useState(0)
250-
const [embedModalKey, setEmbedModalKey] = useState(0)
251-
const [gpxModalKey, setGpxModalKey] = useState(0)
250+
const [embedModalKey, setEmbedModalKey] = useState(1)
251+
const [gpxModalKey, setGpxModalKey] = useState(2)
252252
const [showPublishNotify, setShowPublishNotify] = useState(false)
253253
const [editingEmbed, setEditingEmbed] = useState<DetectedEmbed | null>(null)
254254
const [imageInitialValues, setImageInitialValues] =

apps/web/components/MainLayout/__snapshots__/MainLayout.spec.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ exports[`MainLayout should render successfully 1`] = `
907907
</main>
908908
<div
909909
class="CookieConsent"
910-
style="align-items: center; background: rgb(251, 251, 251); color: white; display: flex; flex-wrap: wrap; justify-content: space-between; left: 0px; position: fixed; width: 100%; z-index: 999; font-family: var(--font-roboto-mono); bottom: 0px;"
910+
style="align-items: center; background: rgb(251, 251, 251); color: white; display: flex; flex-wrap: wrap; justify-content: space-between; left: 0px; position: fixed; width: 100%; z-index: 999; font-family: var(--font-roboto-mono); padding-bottom: max(env(safe-area-inset-bottom), 16px); bottom: 0px;"
911911
>
912912
<div
913913
class=""

apps/web/components/MainLayout/components/CookieBanner/CookieBanner.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export function CookieBanner() {
2121
background: mainTheme.colors.white,
2222
fontFamily: mainTheme.fonts.bodyFont,
2323
alignItems: 'center',
24+
paddingBottom: 'max(env(safe-area-inset-bottom), 16px)',
2425
}}
2526
acceptOnScroll
2627
acceptOnScrollPercentage={75}

apps/web/components/SeriesIndicator/SeriesIndicator.spec.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const mockSeriesPost = (overrides: Record<string, unknown> = {}) => ({
2121
title: 'Part One',
2222
slug: 'part-one',
2323
seriesId: 'my-series',
24+
seriesTitle: 'My Series Title',
2425
seriesOrder: 1,
2526
status: 'published' as const,
2627
category: 'engineering',
@@ -73,6 +74,37 @@ describe('SeriesIndicator', () => {
7374
expect(screen.getByText(/seriesIndicator\.heading/)).toBeInTheDocument()
7475
})
7576

77+
it('uses translated series title in heading, not raw series id', async () => {
78+
mockGetPostsBySeries.mockResolvedValue([
79+
mockSeriesPost({ seriesTitle: 'My Great Series' }),
80+
])
81+
const result = await SeriesIndicator({
82+
postId: '01JX002',
83+
seriesId: 'my-series',
84+
seriesOrder: null,
85+
lng: 'en',
86+
})
87+
renderApp(result)
88+
const heading = screen.getByText(/seriesIndicator\.heading/)
89+
expect(heading.textContent).toContain('My Great Series')
90+
expect(heading.textContent).not.toContain('my-series')
91+
})
92+
93+
it('falls back to seriesId in heading when seriesTitle is null', async () => {
94+
mockGetPostsBySeries.mockResolvedValue([
95+
mockSeriesPost({ seriesTitle: null }),
96+
])
97+
const result = await SeriesIndicator({
98+
postId: '01JX002',
99+
seriesId: 'my-series',
100+
seriesOrder: null,
101+
lng: 'en',
102+
})
103+
renderApp(result)
104+
const heading = screen.getByText(/seriesIndicator\.heading/)
105+
expect(heading.textContent).toContain('my-series')
106+
})
107+
76108
it('renders part label when seriesOrder is provided', async () => {
77109
mockGetPostsBySeries.mockResolvedValue([mockSeriesPost()])
78110
const result = await SeriesIndicator({

apps/web/components/SeriesIndicator/SeriesIndicator.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ export async function SeriesIndicator({
2121

2222
if (seriesPosts.length === 0) return null
2323

24-
const heading = t('seriesIndicator.heading', { seriesId })
24+
const seriesTitle = seriesPosts[0]?.seriesTitle ?? seriesId
25+
const heading = t('seriesIndicator.heading', { seriesId: seriesTitle })
2526
const partLabel =
2627
seriesOrder != null
2728
? t('seriesIndicator.part', { order: seriesOrder })

0 commit comments

Comments
 (0)