('button:not(:disabled)') ?? [])]
+ if (items.length === 0) return
+ const at = items.indexOf(document.activeElement as HTMLButtonElement)
+ const next = e.key === 'ArrowDown' ? (at + 1) % items.length : (at - 1 + items.length) % items.length
+ items[next]?.focus()
+ }
+
useLayoutEffect(() => {
if (!menu || !ref.current) return
const el = ref.current
@@ -69,7 +94,7 @@ export function ContextMenu({ menu, onClose }: ContextMenuProps) {
if (!menu) return null
return createPortal(
- > = {}) {
+function installAtlasHandlers(over: Partial> = {}) {
server.use(
http.get('/api/addons/atlas/stats', () => HttpResponse.json(over.stats ?? statsResponse)),
http.get('/api/addons/atlas/bucket-list', () => HttpResponse.json({ items: over.bucket ?? [] })),
@@ -298,7 +298,7 @@ function regionCodesOf(layer: MockGeoJson | undefined): string[] {
}
async function mountAtlas(over: Partial> = {}, props: { withPanel?: boolean } = {}) {
- useAtlasHandlers(over);
+ installAtlasHandlers(over);
const view = render();
await waitFor(() => expect(atlas.loading).toBe(false));
return view;
@@ -332,7 +332,7 @@ describe('useAtlas', () => {
});
it('FE-HOOK-ATLAS-002: a failing stats request still ends the loading state', async () => {
- useAtlasHandlers();
+ installAtlasHandlers();
server.use(http.get('/api/addons/atlas/stats', () => HttpResponse.error()));
render();
@@ -468,7 +468,7 @@ describe('useAtlas', () => {
});
it('FE-HOOK-ATLAS-011b: unmarking survives atlas data that never loaded', async () => {
- useAtlasHandlers();
+ installAtlasHandlers();
server.use(
http.get('/api/addons/atlas/stats', () => HttpResponse.error()),
http.delete('/api/addons/atlas/country/:code/mark', () => HttpResponse.json({ ok: true })),
@@ -836,7 +836,7 @@ describe('useAtlas', () => {
});
it('FE-HOOK-ATLAS-028: a failing plugin request simply leaves the map untinted', async () => {
- useAtlasHandlers({ geo: geoCountries });
+ installAtlasHandlers({ geo: geoCountries });
server.use(http.get('/api/atlas-layers', () => HttpResponse.error()));
render();
await waitFor(() => expect(atlas.loading).toBe(false));