fix(mobile): keep the photo viewers clear of a side notch in right to left languages

The screen insets stay on their own physical sides when the text runs right to left, so the close button no longer sits under the camera in landscape.
This commit is contained in:
Maurice
2026-11-28 00:33:48 +01:00
parent 5685cdfe13
commit 5c5c468489
4 changed files with 22 additions and 6 deletions
@@ -1,4 +1,4 @@
// FE-COMP-LIGHTBOX-001 to FE-COMP-LIGHTBOX-029
// FE-COMP-LIGHTBOX-001 to FE-COMP-LIGHTBOX-030
// Plyr needs a real media pipeline, so the player is stubbed here.
vi.mock('./VideoPlayer', () => ({
@@ -305,6 +305,13 @@ describe('PhotoLightbox', () => {
fireEvent.touchEnd(surface, { changedTouches: [{ clientX: 100, clientY: 210 }] });
expect(screen.getByText('2 / 3')).toBeInTheDocument();
});
it('FE-COMP-LIGHTBOX-030: the left inset of the screen stays on the left, where the close button now sits', () => {
render(<PhotoLightbox photos={samplePhotos} onClose={vi.fn()} />);
const style = screen.getByRole('dialog').style;
expect(style.paddingInlineEnd).toContain('safe-area-inset-left');
expect(style.paddingInlineStart).toContain('safe-area-inset-right');
});
});
it('FE-COMP-LIGHTBOX-027: a caption with a source page links to it in a new tab, one without stays text', () => {
@@ -144,8 +144,9 @@ export default function PhotoLightbox({ photos, startIndex = 0, onClose, label }
background: 'rgba(0,0,0,0.92)', backdropFilter: 'blur(20px)',
display: 'flex', flexDirection: 'column',
paddingBottom: SAFE('bottom'),
paddingInlineStart: SAFE('left'),
paddingInlineEnd: SAFE('right'),
// The insets belong to the screen's sides, which right to left swaps.
paddingInlineStart: SAFE(rtl ? 'right' : 'left'),
paddingInlineEnd: SAFE(rtl ? 'left' : 'right'),
}}
onTouchStart={onTouchStart}
onTouchMove={onTouchMove}
@@ -52,10 +52,11 @@ export default function MFileLightbox({ files, index, onIndexChange, onClose, t
>
{/* Header */}
{/* Below the status bar and a notch, and clear of a side inset in landscape,
so the close button is always there to tap. */}
so the close button is always there to tap. The insets are the screen's
sides, so right to left takes them the other way round. */}
<div
role="presentation"
className="flex flex-none items-center justify-between gap-2 pb-[10px] pe-[calc(var(--m-safe-r)+12px)] ps-[calc(var(--m-safe-l)+16px)] pt-[calc(var(--m-safe-t)+10px)]"
className="flex flex-none items-center justify-between gap-2 pb-[10px] pe-[calc(var(--m-safe-r)+12px)] ps-[calc(var(--m-safe-l)+16px)] pt-[calc(var(--m-safe-t)+10px)] rtl:pe-[calc(var(--m-safe-l)+12px)] rtl:ps-[calc(var(--m-safe-r)+16px)]"
onClick={e => e.stopPropagation()}
>
<span className="min-w-0 flex-1 truncate font-geist text-[0.75rem] text-white/70">
@@ -5,7 +5,7 @@ import { downloadFile, openFile } from '../../../../src/utils/fileDownload'
import type { TranslationFn, TripFile } from '../../../../src/types'
import { fireEvent, render, screen, waitFor } from '../../../helpers/render'
// FE-MOB-FLBOX-001 to FE-MOB-FLBOX-017
// FE-MOB-FLBOX-001 to FE-MOB-FLBOX-018
vi.mock('../../../../src/api/authUrl', () => ({
getAuthUrl: vi.fn(async (url: string) => `${url}?token=t1`),
@@ -230,4 +230,11 @@ describe('MFileLightbox', () => {
expect(screen.getByAltText('castle.png')).toHaveAttribute('src', '/api/trips/1/files/2/download?token=t1'),
)
})
it('FE-MOB-FLBOX-018: right to left, the header keeps each side inset on its own screen side', () => {
renderBox(0)
const header = screen.getByText('beach.jpg').closest('[role="presentation"]') as HTMLElement
expect(header.className).toContain('rtl:ps-[calc(var(--m-safe-r)+16px)]')
expect(header.className).toContain('rtl:pe-[calc(var(--m-safe-l)+12px)]')
})
})