fix(mobile): the filter pill hugs its chips and the list switcher clears the dock (#2104)

On wider phones the dashboard filter pill stretched across the leftover width instead of wrapping its chips. The collections list switcher could not scroll, so its lower entries and the new-list button hid behind the dock.
This commit is contained in:
Maurice
2026-09-02 19:01:17 +02:00
committed by Maurice
parent 3f49ef8d21
commit 1428637694
4 changed files with 37 additions and 10 deletions
@@ -169,9 +169,11 @@ export default function MCollections() {
)}
</div>
{/* List switcher dropdown (in flow, like the design) */}
{/* List switcher dropdown (in flow, like the design). In map view it is a
flex item of a viewport-high column, so it has to cap itself and give
way rather than push its last entries under the dock (#2104). */}
{drop && (
<div className="-mt-[6px] mb-3 rounded-2xl border border-[color:var(--m-rowbr)] bg-m-sheetop p-[6px] shadow-[0_16px_40px_-20px_rgba(0,0,0,.4)]">
<div className="-mt-[6px] mb-3 max-h-[50dvh] min-h-0 overflow-y-auto rounded-2xl border border-[color:var(--m-rowbr)] bg-m-sheetop p-[6px] shadow-[0_16px_40px_-20px_rgba(0,0,0,.4)]">
<button
type="button"
onClick={() => selectList(ALL_SAVED)}
@@ -132,12 +132,13 @@ export default function MDashboard(): React.ReactElement {
return (
<>
<div className="mt-[14px] flex items-center gap-[7px]">
{/* The chips scroll inside their own flexible box on narrow viewports
or large system font scales; without it this row was the widest
thing on the page and dragged the fixed bars off-screen under
Android's forced zoom. min-w-max keeps the pill track wrapping
its chips instead of getting squeezed to the box. */}
<div className="m-hscroll min-w-0 flex-1">
{/* The chips scroll inside their own box on narrow viewports or large
system font scales; without it this row was the widest thing on
the page and dragged the fixed bars off-screen under Android's
forced zoom. min-w-max keeps the pill track wrapping its chips,
and the box stays content-wide (no flex-1) so the pill still hugs
them on wide phones while ml-auto parks the icons on the right. */}
<div className="m-hscroll min-w-0">
<MSegmented<TripFilter>
value={tripFilter}
onChange={setTripFilter}
@@ -150,7 +151,7 @@ export default function MDashboard(): React.ReactElement {
]}
/>
</div>
<MIconBtn ariaLabel={t('dashboard.subscribeAllTrips')} size={36} className="flex-none" onClick={() => setSubOpen(true)}>
<MIconBtn ariaLabel={t('dashboard.subscribeAllTrips')} size={36} className="ml-auto" onClick={() => setSubOpen(true)}>
<CalendarPlus size={15} strokeWidth={2} className="text-m-muted" />
</MIconBtn>
<button
@@ -490,6 +490,19 @@ describe('MCollections', () => {
expect(container.firstElementChild!.className).not.toContain('h-dvh')
})
it('FE-MOB-COLSCR-019d: the open list switcher scrolls instead of hiding its last entries behind the dock (#2104)', () => {
mocks.coll = makeHook({ view: 'map' })
render(<MCollections />)
fireEvent.click(switcher())
// In the viewport-high map column the panel is the only item that can give
// way, so it has to cap and scroll itself to keep "new list" reachable.
const panel = screen.getByRole('button', { name: /collections.newList/ }).parentElement!
expect(panel.className).toContain('overflow-y-auto')
expect(panel.className).toContain('min-h-0')
expect(panel.className).toMatch(/max-h-\[/)
})
it('FE-MOB-COLSCR-020: a map view with nothing mappable falls back to the empty note', () => {
mocks.coll = makeHook({ view: 'map', mappable: [] })
render(<MCollections />)
@@ -552,6 +552,17 @@ describe('MDashboard', () => {
const wrapper = track.parentElement as HTMLElement;
expect(wrapper.className).toContain('m-hscroll');
expect(wrapper.className).toContain('min-w-0');
expect(wrapper.className).toContain('flex-1');
});
it('FE-MOB-DASH-039: the filter pill hugs its chips instead of filling the row', async () => {
render(<MDashboard />);
// flex-1 on the scroll box stretched the grey pill track all the way to the
// calendar icon on phones from ~400px up; the icons ride on ml-auto instead.
const chip = await screen.findByText('dashboard.filter.planned');
const wrapper = chip.closest('button')!.parentElement!.parentElement as HTMLElement;
expect(wrapper.className).not.toContain('flex-1');
expect(screen.getByRole('button', { name: 'dashboard.subscribeAllTrips' }).className)
.toContain('ml-auto');
});
});