feat(document-picker): optional inputId prop for external label wiring (#795)
The input always carries an id (generated doc-picker-input-{uid} default,
mirroring the listbox id scheme). When a caller passes inputId it wires a
visible <label for> — the aria-label fallback is dropped then so the
visible label wins. JourneyAddBar stays untouched.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -241,3 +241,21 @@ describe('DocumentPickerDropdown — ARIA listbox integrity', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('DocumentPickerDropdown — external label wiring (#795)', () => {
|
||||
it('renders a generated default id on the input and keeps the aria-label fallback', async () => {
|
||||
render(DocumentPickerDropdown, { onSelect: vi.fn() });
|
||||
|
||||
const input = page.getByRole('combobox').element() as HTMLInputElement;
|
||||
expect(input.id).toMatch(/^doc-picker-input-/);
|
||||
expect(input.getAttribute('aria-label')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('uses the provided inputId and drops the aria-label so an external label wins', async () => {
|
||||
render(DocumentPickerDropdown, { onSelect: vi.fn(), inputId: 'story-doc-picker' });
|
||||
|
||||
const input = page.getByRole('combobox').element() as HTMLInputElement;
|
||||
expect(input.id).toBe('story-doc-picker');
|
||||
expect(input.getAttribute('aria-label')).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user