fix(mobile): no how-to line on the 3D map on a tablet

This commit is contained in:
Maurice
2026-11-08 12:13:20 +01:00
parent 53c18b861a
commit b73f749880
2 changed files with 17 additions and 0 deletions
@@ -1,6 +1,7 @@
// FE-COMP-TERRAIN-001 to FE-COMP-TERRAIN-018
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { act, fireEvent, render, screen, waitFor } from '../../../../tests/helpers/render';
import { resetSizeClass, setSizeClass } from '../../../../tests/helpers/sizeClass';
import type { DistanceIndexedProfileSample, RouteProfileFocus } from '../../../utils/routeGeometry';
import TourTerrainMap, { type TourTerrainMapProps } from './TourTerrainMap';
@@ -257,6 +258,17 @@ describe('TourTerrainMap', () => {
expect(screen.queryByRole('button', { name: 'Play flyover' })).toBeNull();
});
it('FE-COMP-TERRAIN-002b: on an iPad or an unfolded foldable the how-to line stays out of the map', async () => {
setSizeClass('split');
try {
await renderTerrain();
expect(screen.queryByText('Open a tour on the right to fly it in 3D and colour it by grade.')).toBeNull();
expect(screen.queryByText(/Click the terrain to set points/)).toBeNull();
} finally {
resetSizeClass();
}
});
it('FE-COMP-TERRAIN-003: a click on the terrain adds a control point only while editing', async () => {
const onAdd = vi.fn();
const { rerender } = await renderTerrain({ waypoints: { points: [], selectedId: null, onSelect: vi.fn(), onAdd } });
@@ -1,6 +1,7 @@
import type { FerrataBbox } from '@trek/shared';
import { ChevronDown, ChevronUp, Gauge, Palette, Pause, Play, RotateCcw, Scan, TrendingUp } from 'lucide-react';
import { useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type ReactNode } from 'react';
import { useIsWide } from '../../../hooks/sizeClass';
import { useTranslation } from '../../../i18n';
import type { DistanceUnit } from '../../../types';
import type { DistanceIndexedProfileSample, RouteProfileFocus } from '../../../utils/routeGeometry';
@@ -84,6 +85,7 @@ export default function TourTerrainMap(props: TourTerrainMapProps) {
const { setContainer, ...terrain } = useTourTerrain({ ...props, panels: { leftWidth, rightWidth } });
const stats = useMemo(() => terrainStats(samples), [samples]);
const { fit, height: controlsHeight, attachRow, attachStack } = useControlRowFit();
const touchShell = useIsWide();
const legend =
terrain.canReplay && !props.water ? (
<GradeLegend stats={stats} unit={unit} onLayout={props.onLegendLayout} />
@@ -134,6 +136,9 @@ export default function TourTerrainMap(props: TourTerrainMapProps) {
<span />
{terrain.canReplay ? (
<TerrainDock terrain={terrain} water={props.water} />
) : touchShell ? (
// A tablet's map is short on room, and its user learns the gestures by touch: no how-to line.
<span />
) : (
<div
className="pointer-events-auto rounded-full px-4 py-2.5 text-content-muted"