Skip to content

Commit

Permalink
feat: add support for pointerenter and pointerleave events as a worka…
Browse files Browse the repository at this point in the history
…round for bug #1613
  • Loading branch information
norbertkeresztes authored and Norbert Keresztes committed Dec 6, 2022
1 parent 57091a2 commit be9c8ed
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
Expand Up @@ -83,6 +83,8 @@ const tests: [EventName, DayEventName][] = [
['onBlur', 'onDayBlur'],
['onMouseEnter', 'onDayMouseEnter'],
['onMouseLeave', 'onDayMouseLeave'],
['onPointerEnter', 'onDayPointerEnter'],
['onPointerLeave', 'onDayPointerLeave'],
['onTouchEnd', 'onDayTouchEnd'],
['onTouchCancel', 'onDayTouchCancel'],
['onTouchMove', 'onDayTouchMove'],
Expand Down
Expand Up @@ -24,6 +24,8 @@ export type EventName =
| 'onKeyUp'
| 'onMouseEnter'
| 'onMouseLeave'
| 'onPointerEnter'
| 'onPointerLeave'
| 'onTouchCancel'
| 'onTouchEnd'
| 'onTouchMove'
Expand All @@ -37,6 +39,8 @@ export type DayEventName =
| 'onDayKeyUp'
| 'onDayMouseEnter'
| 'onDayMouseLeave'
| 'onDayPointerEnter'
| 'onDayPointerLeave'
| 'onDayTouchCancel'
| 'onDayTouchEnd'
| 'onDayTouchMove'
Expand Down Expand Up @@ -115,6 +119,12 @@ export function useDayEventHandlers(
const onMouseLeave: MouseEventHandler = (e) => {
dayPicker.onDayMouseLeave?.(date, activeModifiers, e);
};
const onPointerEnter: MouseEventHandler = (e) => {
dayPicker.onDayPointerEnter?.(date, activeModifiers, e);
};
const onPointerLeave: MouseEventHandler = (e) => {
dayPicker.onDayPointerLeave?.(date, activeModifiers, e);
};
const onTouchCancel: TouchEventHandler = (e) => {
dayPicker.onDayTouchCancel?.(date, activeModifiers, e);
};
Expand Down Expand Up @@ -186,6 +196,8 @@ export function useDayEventHandlers(
onKeyUp,
onMouseEnter,
onMouseLeave,
onPointerEnter,
onPointerLeave,
onTouchCancel,
onTouchEnd,
onTouchMove,
Expand Down
2 changes: 2 additions & 0 deletions packages/react-day-picker/src/types/DayPickerBase.ts
Expand Up @@ -251,6 +251,8 @@ export interface DayPickerBase {
onDayKeyDown?: DayKeyboardEventHandler;
onDayKeyUp?: DayKeyboardEventHandler;
onDayKeyPress?: DayKeyboardEventHandler;
onDayPointerEnter?: DayMouseEventHandler;
onDayPointerLeave?: DayMouseEventHandler;
onDayTouchCancel?: DayTouchEventHandler;
onDayTouchEnd?: DayTouchEventHandler;
onDayTouchMove?: DayTouchEventHandler;
Expand Down

0 comments on commit be9c8ed

Please sign in to comment.