Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(DatePicker): ensure down arrow opens calendar dropdown #5326

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions packages/react/src/components/DatePicker/DatePicker-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,3 +399,25 @@ describe('DatePickerSkeleton', () => {
});
});
});

describe('Opening up calendar dropdown', () => {
const wrapper = mount(
<DatePicker datePickerType="range" className="extra-class">
<DatePickerInput labelText="Date Picker label" id="input-from" />
<DatePickerInput labelText="Date Picker label" id="input-to" />
</DatePicker>
);

it('has the range date picker with min and max dates', () => {
const datePicker = wrapper.instance();
const input = wrapper.find('input').at(0);

jest.spyOn(datePicker.cal, 'open');

input
.getDOMNode()
.dispatchEvent(new window.KeyboardEvent('keydown', { key: 'ArrowDown' }));

expect(datePicker.cal.open).toHaveBeenCalled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export default config => fp => {
// so user can move the keyboard cursor for editing dates
// Workaround for: https://github.com/flatpickr/flatpickr/issues/1943
event.stopPropagation();
} else if (match(event, keys.ArrowDown)) {
event.preventDefault();
fp.open();
}
}
};
Expand Down