Skip to content

Commit

Permalink
fix(datepicker): apply id on label's htmlFor attribute (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurdenner committed May 28, 2020
1 parent b3a7e3e commit 4d9ffb1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/__tests__/datepicker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,16 @@ describe('Basic datepicker', () => {
expect(datePickerInput.value).toBe('');
});

it('should be accessible when id is provided', () => {
const { getByLabelText, getByText } = setup({
id: 'click-me',
label: 'Click me',
});

fireEvent.click(getByLabelText('Click me'));
expect(getByText('Today')).toBeTruthy();
});

describe('clearOnSameDateClick', () => {
it('reset its state when prop is true', () => {
const { datePickerInput, getByText, openDatePicker } = setup({
Expand Down
2 changes: 1 addition & 1 deletion src/components/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const CustomInput = React.forwardRef<Input, InputProps>((props, ref) => {

return (
<Form.Field>
{label && <label>{label}</label>}
{label && <label htmlFor={rest.id as string | undefined}>{label}</label>}
<Input
data-testid="datepicker-input"
{...rest}
Expand Down

1 comment on commit 4d9ffb1

@vercel
Copy link

@vercel vercel bot commented on 4d9ffb1 May 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.