fix(tours): format the dropdown changes and lower the hook ref baseline

The editor dropdown change drops the options ref useAnchoredPosition kept
for its measure callback, so the react-hooks/refs count falls by one and
the baseline follows it. The new and touched files are formatted, and the
new rail test gets its id like the rest of the file.
This commit is contained in:
Maurice
2026-11-27 20:03:41 +01:00
parent 20c8457f18
commit 3dd63331bc
6 changed files with 219 additions and 163 deletions
@@ -825,7 +825,7 @@ describe('TourPlannerRail', () => {
expect(screen.getAllByRole('status').some(el => /T3 routes may include exposed/.test(el.textContent ?? ''))).toBe(true)
})
it('dismisses an open tour type list when saving locks the editor', () => {
it('TOUR-PLANNER-RAIL-024: an open tour type list closes when saving locks the editor', () => {
const controller = planner({ mode: { type: 'new-draft' } })
const { rerender } = render(<TourPlannerRail planner={controller} />)
const trigger = screen.getByTestId('tour-type-select')
@@ -121,7 +121,12 @@ function SkiFields({ planner, locked }: TourTypeFieldsProps) {
{t('tours.ski.plannedHint')}
</span>
{choice.discipline !== null && (
<SkiRouteOptions discipline={choice.discipline} options={choice.options} onChange={planner.ski.setOption} locked={locked} />
<SkiRouteOptions
discipline={choice.discipline}
options={choice.options}
onChange={planner.ski.setOption}
locked={locked}
/>
)}
</div>
);
@@ -4,13 +4,18 @@ import { useAnchoredPosition } from '../../hooks/useAnchoredPosition';
/** The scrolling content that contains a panel's dropdown triggers. */
export const PopoverBoundary = createContext<RefObject<HTMLElement | null> | null>(null);
export function useAnchoredPopover(anchorRef: RefObject<HTMLElement | null>, {
disabled = false, estimatedHeight, matchWidth = true,
}: {
disabled?: boolean;
estimatedHeight?: number;
matchWidth?: boolean;
}) {
export function useAnchoredPopover(
anchorRef: RefObject<HTMLElement | null>,
{
disabled = false,
estimatedHeight,
matchWidth = true,
}: {
disabled?: boolean;
estimatedHeight?: number;
matchWidth?: boolean;
}
) {
const boundaryRef = use(PopoverBoundary);
const bounded = !!boundaryRef;
const unavailable = bounded && disabled;
+10 -4
View File
@@ -13,10 +13,16 @@ const EDGE = 8;
* it and goes on from the button; a click beside it closes it. The caller draws
* the button and the list and hands `currentIndex`, the choice held now.
*/
export function usePopoverList(currentIndex: number, { estimatedHeight = 320, disabled }: {
estimatedHeight?: number;
disabled?: boolean;
} = {}) {
export function usePopoverList(
currentIndex: number,
{
estimatedHeight = 320,
disabled,
}: {
estimatedHeight?: number;
disabled?: boolean;
} = {}
) {
const triggerRef = useRef<HTMLButtonElement>(null);
const menuRef = useRef<HTMLDivElement>(null);
const startAt = useRef(0);