Skip to content

Commit

Permalink
fix(DatePicker): ensure down arrow opens calendar dropdown (#5326)
Browse files Browse the repository at this point in the history
Refs #5310.
  • Loading branch information
asudoh committed Feb 13, 2020
1 parent 453f94c commit 57914e5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
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

0 comments on commit 57914e5

Please sign in to comment.