Skip to content

Commit b2de2ef

Browse files
committed
fix(console): name the map key pickers by the key column header
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jUhVXEJm46XTxRs4GM
1 parent 571bb6a commit b2de2ef

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

‎ui/apps/console/src/pages/settings/SettingsMapField.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@ export function SettingsMapField({
296296
const unused = served.filter((o) => !usedKeys.has(o.value));
297297
const keyHeader = pickLocalized(spec.keyColumn?.label, language);
298298
const columnLabels = columns.map((c) => pickLocalized(c.label, language));
299+
// Each row's key picker is named by the key column's header: a combobox
300+
// takes its name from its label, never from the option it shows.
301+
const keyHeaderId = `${labelId}-key`;
299302
const searchText = t('console.settingsView.mapSearchKey');
300303
const emptyText = t('common.noResults');
301304

@@ -304,7 +307,7 @@ export function SettingsMapField({
304307
<Table aria-describedby={errorAt ? undefined : describedBy}>
305308
<TableHeader>
306309
<TableRow>
307-
<TableHead>{keyHeader}</TableHead>
310+
<TableHead id={keyHeaderId}>{keyHeader}</TableHead>
308311
{columns.map((c, i) => (
309312
<TableHead key={c.name} title={c.description}>
310313
{columnLabels[i]}
@@ -346,6 +349,7 @@ export function SettingsMapField({
346349
disabled={disabled}
347350
searchPlaceholder={searchText}
348351
emptyText={emptyText}
352+
aria-labelledby={keyHeaderId}
349353
aria-invalid={keyMarked || undefined}
350354
aria-describedby={keyMarked ? describedBy : undefined}
351355
className={cn('w-56', keyMarked && 'border-destructive')}
@@ -409,6 +413,7 @@ export function SettingsMapField({
409413
value=""
410414
disabled={disabled || unused.length === 0}
411415
placeholder={t('console.settingsView.mapAddRow')}
416+
aria-label={t('console.settingsView.mapAddRow')}
412417
searchPlaceholder={searchText}
413418
emptyText={emptyText}
414419
className="w-56"

‎ui/apps/console/src/pages/settings/__tests__/SettingsView.mapRows-31391.test.tsx‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ describe('SettingsView — a `map` setting draws its stored rows (objectstack#31
156156
expect(entryKeys('quotas')).toEqual(['sys_job_run', 'sys_audit_log']);
157157
expect(cell('quotas', 'sys_audit_log', 'Max rows').value).toBe('1000000');
158158
// The key cell shows the served label, the header the declared key column.
159-
expect(within(entryRow('quotas', 'sys_audit_log')!).getByRole('combobox').textContent).toContain('Audit log');
159+
const keyPicker = within(entryRow('quotas', 'sys_audit_log')!).getByRole('combobox', { name: 'Object' });
160+
expect(keyPicker.textContent).toContain('Audit log');
160161
expect(within(rowFor('quotas')).getByRole('columnheader', { name: 'Object' })).toBeTruthy();
161162
// The row is drawn as keyed rows, never as the unsupported-type fallback.
162163
expect(rowFor('quotas').textContent).not.toMatch(/unsupportedSpecifierType/);
@@ -288,7 +289,7 @@ describe('SettingsView — a refused map save marks the row it names (objectstac
288289

289290
await waitFor(() => expect(entryRow('quotas', 'sys_audit_logs')!.dataset.invalid).toBe('true'));
290291
expect(entryRow('quotas', 'sys_job_run')!.dataset.invalid).toBeUndefined();
291-
const keyPicker = within(entryRow('quotas', 'sys_audit_logs')!).getByRole('combobox');
292+
const keyPicker = within(entryRow('quotas', 'sys_audit_logs')!).getByRole('combobox', { name: 'Object' });
292293
expect(keyPicker.getAttribute('aria-invalid')).toBe('true');
293294
const alert = rowFor('quotas').querySelector('[role="alert"]')!;
294295
expect(alert.textContent).toBe(sentence);
@@ -318,7 +319,7 @@ describe('SettingsView — a refused map save marks the row it names (objectstac
318319
expect(cell('retention_overrides', 'sys_job_run', 'Expire rows after').getAttribute('aria-invalid')).toBe('true');
319320
expect(cell('retention_overrides', 'sys_job_run', 'Keep rows for').getAttribute('aria-invalid')).toBeNull();
320321
expect(
321-
within(entryRow('retention_overrides', 'sys_job_run')!).getByRole('combobox', { name: /Job run/ }).getAttribute('aria-invalid'),
322+
within(entryRow('retention_overrides', 'sys_job_run')!).getByRole('combobox', { name: 'Object' }).getAttribute('aria-invalid'),
322323
).toBeNull();
323324
});
324325

@@ -357,7 +358,8 @@ describe('SettingsView — a locked map (objectstack#31391)', () => {
357358
await screen.findByText('Row quotas');
358359

359360
expect(cell('quotas', 'sys_audit_log', 'Max rows').disabled).toBe(true);
360-
expect((within(entryRow('quotas', 'sys_audit_log')!).getByRole('combobox') as HTMLButtonElement).disabled).toBe(true);
361+
const keyPicker = within(entryRow('quotas', 'sys_audit_log')!).getByRole('combobox', { name: 'Object' });
362+
expect((keyPicker as HTMLButtonElement).disabled).toBe(true);
361363
expect((addPicker('quotas') as HTMLButtonElement).disabled).toBe(true);
362364
const remove = within(rowFor('quotas')).getByRole('button', { name: /mapRemoveRow/ }) as HTMLButtonElement;
363365
expect(remove.disabled).toBe(true);

0 commit comments

Comments
 (0)