fix(client): preserve explicit dialog focus and verify accessible controls

Keep the focused search for new places and title fields in explicitly opened dialogs. Assert the native ride badge button and the pointer grip tooltip in the existing tests.
This commit is contained in:
Maurice
2026-12-01 21:13:35 +01:00
parent e539860530
commit 756ef14b97
4 changed files with 6 additions and 5 deletions
@@ -269,7 +269,7 @@ describe('PackingListPanel', () => {
const { container } = render(<PackingListPanel tripId={1} items={items} sort="name" />);
// Only the category grip stays: the order of the categories is not the A to Z of their items.
const draggable = [...container.querySelectorAll('[draggable="true"]')];
expect(draggable.map((el) => el.getAttribute('aria-label'))).toEqual(['Drag to reorder the category']);
expect(draggable.map((el) => el.getAttribute('title'))).toEqual(['Drag to reorder the category']);
});
it('FE-COMP-PACKING-023: inline edit item name via pencil icon calls PUT', async () => {
@@ -12,6 +12,7 @@ import { PendingFiles, PlaceImageSection } from './PlaceFormMedia'
import { usePlaceImageField } from './usePlaceImageField'
import { useToast } from '../shared/Toast'
import { Tooltip } from '../shared/Tooltip'
import { focusRevealedEditor } from '../shared/dialogFocus'
import { Search, RotateCcw, LocateFixed, PencilLine } from 'lucide-react'
import { useTranslation } from '../../i18n'
import { PlaceContactFields } from './PlaceContactFields'
@@ -644,7 +645,7 @@ export default function PlaceFormModal(props: PlaceFormModalProps) {
type="text"
// A new place starts at the search; an edit or a place brought
// in from the map already has what the search would give.
data-initial-focus={(!place && !prefillCoords) || undefined}
ref={!place && !prefillCoords ? focusRevealedEditor : undefined}
value={mapsSearch}
onChange={e => { setMapsSearch(e.target.value); S.setEmptySearch(null) }}
onKeyDown={handleSearchKeyDown}
@@ -98,7 +98,7 @@ describe('a ride taken from a GPX file (HOR-02)', () => {
expect(facts).toHaveTextContent('No riding time');
expect(facts).toHaveTextContent('Access not checked');
// Each reason is the badge's description, reachable without a pointer.
const access = screen.getByText('Access not checked').closest('[tabindex="0"]') as HTMLElement;
const access = screen.getByRole('button', { name: 'Access not checked' });
expect(access).toHaveAccessibleDescription(
'The import does not check whether the ways may be ridden. The signs on site count.'
);
+2 -2
View File
@@ -4,7 +4,7 @@ import { Trash2, X } from 'lucide-react'
import { useTranslation } from '../../i18n'
import { lockBodyScroll } from '../../utils/bodyScrollLock'
import { Tooltip } from './Tooltip'
import { focusDialog, trapTab } from './dialogFocus'
import { focusDialog, focusRevealedEditor, trapTab } from './dialogFocus'
import { useDiscardGuard } from './useDiscardGuard'
/** A font size that follows the user's text size setting for its tier. */
@@ -252,7 +252,7 @@ export function DialogHeader(p: DialogHeaderProps) {
onBlur={f.onBlur}
aria-label={f.label}
placeholder={f.placeholder}
data-initial-focus={f.autoFocus || undefined}
ref={f.autoFocus ? focusRevealedEditor : undefined}
required={f.required}
maxLength={f.maxLength}
className="-mx-2 block w-[calc(100%+16px)] rounded-[10px] border-0 bg-transparent px-2 py-0.5 font-bold tracking-[-0.01em] text-content outline-none placeholder:font-semibold placeholder:text-content-faint hover:bg-surface-card focus:bg-surface-card focus:shadow-sm dark:bg-transparent dark:hover:bg-surface-card dark:focus:bg-surface-card"