Skip to content

Commit

Permalink
refactor: use createOnKeyDown
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraghazra committed Sep 22, 2020
1 parent 44498c6 commit c20205f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/calendar-v1/RangeCalendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* to work with Reakit System
*/
import { BoxOptions } from "reakit";
import { createOnKeyDown } from "reakit-utils";
import { createComponent, createHook } from "reakit-system";

import { RANGE_CALENDAR_KEYS } from "./__keys";
Expand All @@ -27,14 +28,14 @@ export const useRangeCalendar = createHook<
keys: RANGE_CALENDAR_KEYS,

useProps({ setAnchorDate }, htmlProps) {
const onKeyDown = (e: any) => {
switch (e.key) {
case "Escape":
const onKeyDown = createOnKeyDown({
keyMap: {
Escape: () => {
// Cancel the selection.
setAnchorDate(null);
break;
}
};
},
},
});

return {
"aria-multiselectable": true,
Expand Down

0 comments on commit c20205f

Please sign in to comment.