From 35b3ff0c9e5defc7644310c8ce0633de9323f676 Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 4 Dec 2026 12:03:52 +0100 Subject: [PATCH] fix(mobile): refine place headings and segmented tabs Keep the category icon separately labeled beside the heading and verify both photo and plain headers. Give the five translated place tabs a full-width segmented surface with room for their count badges. --- .../collections/MPlaceSheetShell.test.tsx | 11 +++- .../screens/collections/MPlaceSheetShell.tsx | 39 ++++++----- .../screens/collections/MPlaceSheetTabs.tsx | 66 +++++++++---------- .../collections/MCollPlaceSheet.test.tsx | 17 ++--- .../collections/MLibraryPlaceSheet.test.tsx | 2 +- 5 files changed, 71 insertions(+), 64 deletions(-) diff --git a/client/src/mobile/screens/collections/MPlaceSheetShell.test.tsx b/client/src/mobile/screens/collections/MPlaceSheetShell.test.tsx index 15c94f9c6..ba6cf80e6 100644 --- a/client/src/mobile/screens/collections/MPlaceSheetShell.test.tsx +++ b/client/src/mobile/screens/collections/MPlaceSheetShell.test.tsx @@ -30,11 +30,16 @@ function setup(over: Partial = {}) { } describe('MPlaceSheetShell', () => { - it('FE-MOB-PLACESHEETSHELL-001: the cover names the place, its category and where it is, the body follows', () => { + it('FE-MOB-PLACESHEETSHELL-001: the sheet gives the category icon and heading separate names', () => { setup(); expect(screen.getByRole('dialog', { name: 'Colosseum' })).toBeInTheDocument(); expect(screen.getByRole('heading', { name: 'Colosseum' })).toBeInTheDocument(); - expect(screen.getByText('Sights')).toBeInTheDocument(); + const icon = screen.getByRole('img', { name: 'Sights' }); + expect( + icon.compareDocumentPosition(screen.getByRole('heading', { name: 'Colosseum' })) & + Node.DOCUMENT_POSITION_FOLLOWING + ).toBeTruthy(); + expect(screen.queryByText('Sights')).not.toBeInTheDocument(); expect(screen.getByText('Piazza del Colosseo')).toBeInTheDocument(); expect(screen.getByText('the body')).toBeInTheDocument(); expect(document.querySelector('[role="dialog"] img')).toBeNull(); @@ -82,7 +87,7 @@ describe('MPlaceSheetShell', () => { it('FE-MOB-PLACESHEETSHELL-004: without a name or a category the cover stays bare', () => { setup({ name: null, category: null }); expect(screen.queryByRole('heading')).toBeNull(); - expect(screen.queryByText('Sights')).toBeNull(); + expect(screen.queryByRole('img', { name: 'Sights' })).toBeNull(); expect(screen.queryByText('Piazza del Colosseo')).toBeNull(); }); }); diff --git a/client/src/mobile/screens/collections/MPlaceSheetShell.tsx b/client/src/mobile/screens/collections/MPlaceSheetShell.tsx index 8872ffa6e..8a6d2caa1 100644 --- a/client/src/mobile/screens/collections/MPlaceSheetShell.tsx +++ b/client/src/mobile/screens/collections/MPlaceSheetShell.tsx @@ -96,22 +96,21 @@ export default function MPlaceSheetShell({ const location = name && (address?.trim() || (lat != null && lng != null ? coordsText(lat, lng) : t('places.noCoordinates'))); const coverLabel = t('collections.coverImage'); + const categoryIcon = + category && + createElement(meta.icon, { + className: 'size-4 flex-none', + role: 'img', + 'aria-label': category.name, + }); const placeName = name && ( - <> - {category && - createElement(meta.icon, { - className: 'me-1.5 inline-block size-4 align-[-0.1em]', - role: 'img', - 'aria-label': category.name, - })} - { - titleRef.current = node; - }} - > - {name} - - + { + titleRef.current = node; + }} + > + {name} + ); const closeLabel = t('common.close'); const renderPlaceHeader = () => ( @@ -140,7 +139,12 @@ export default function MPlaceSheetShell({ ) : ( placeName && ( <> -

{placeName}

+
+ {categoryIcon && {categoryIcon}} +

+ {placeName} +

+
) @@ -149,7 +153,8 @@ export default function MPlaceSheetShell({ ) : ( -
- {PLACE_TABS.map((key) => { - const on = tab === key; - return ( - - ); - })} +
+
+ {PLACE_TABS.map((key) => { + const on = tab === key; + return ( + + ); + })} +
{sheet.empty[tab] ? ( diff --git a/client/tests/unit/mobile/collections/MCollPlaceSheet.test.tsx b/client/tests/unit/mobile/collections/MCollPlaceSheet.test.tsx index 99b18f89f..aed691cdb 100644 --- a/client/tests/unit/mobile/collections/MCollPlaceSheet.test.tsx +++ b/client/tests/unit/mobile/collections/MCollPlaceSheet.test.tsx @@ -103,11 +103,11 @@ describe('MCollPlaceSheet', () => { delete window.__addToast }) - it('FE-MOB-CPLSH-001: heads the sheet with the place, its category chip and address', () => { + it('FE-MOB-CPLSH-001: heads the sheet with the place, its category icon and address', () => { setup() expect(screen.getByRole('dialog', { name: 'Narisawa' })).toBeInTheDocument() expect(screen.getByText('Narisawa')).toBeInTheDocument() - expect(screen.getByText('Restaurant')).toBeInTheDocument() + expect(screen.getByRole('img', { name: 'Restaurant' })).toBeInTheDocument() expect(screen.getByText('2-6-15 Minami-Aoyama')).toBeInTheDocument() }) @@ -443,7 +443,6 @@ describe('MCollPlaceSheet', () => { expect(row).toContainElement(camera) expect(camera.compareDocumentPosition(close) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy() expect(camera).toHaveClass('rounded-full', 'bg-m-ic') - expect(row.contains(screen.getByText('Restaurant'))).toBe(false) const input = document.querySelector('input[type="file"]') as HTMLInputElement const clicked = vi.fn() @@ -470,19 +469,17 @@ describe('MCollPlaceSheet', () => { expect(header).toContainElement(screen.getByRole('heading', { name: 'Narisawa' })) }) - it('FE-MOB-CPLSH-041: a long category gets its own line below the header', () => { + it('FE-MOB-CPLSH-041: a long category stays an icon alongside the title', () => { const long = 'Restaurants, cafes and late night bars' setup({ onUploadImage: vi.fn(), place: place({ category: { id: 3, name: long, color: '#E8843D', icon: 'Utensils' }, image_url: '/uploads/places/n.jpg' }), }) - const header = screen.getByRole('button', { name: 'Close' }).parentElement as HTMLElement - const text = screen.getByText(long) - const chip = text.parentElement as HTMLElement + const heading = screen.getByRole('heading', { name: 'Narisawa' }) + const icon = screen.getByRole('img', { name: long }) - expect(header).not.toContainElement(chip) - expect(chip).toHaveClass('max-w-full') - expect(text).toHaveClass('truncate') + expect(heading.parentElement).toContainElement(icon) + expect(screen.queryByText(long)).not.toBeInTheDocument() }) }) diff --git a/client/tests/unit/mobile/collections/MLibraryPlaceSheet.test.tsx b/client/tests/unit/mobile/collections/MLibraryPlaceSheet.test.tsx index 99608318f..8dc57e8cf 100644 --- a/client/tests/unit/mobile/collections/MLibraryPlaceSheet.test.tsx +++ b/client/tests/unit/mobile/collections/MLibraryPlaceSheet.test.tsx @@ -155,7 +155,7 @@ describe('MLibraryPlaceSheet: the place', () => { setup({ cover: '/uploads/cover.jpg' }); expect(screen.getByRole('dialog', { name: 'Colosseum' })).toBeInTheDocument(); expect(screen.getByRole('heading', { name: 'Colosseum' })).toBeInTheDocument(); - expect(screen.getByText('Restaurant')).toBeInTheDocument(); + expect(screen.getByRole('img', { name: 'Restaurant' })).toBeInTheDocument(); expect(screen.getByText('Piazza del Colosseo')).toBeInTheDocument(); expect(screen.getByText('Ancient arena')).toBeInTheDocument(); expect(screen.getByTestId('rating-row')).toBeInTheDocument();