Skip to content

Commit

Permalink
fixes calendar not closing on escape key press (#7008)
Browse files Browse the repository at this point in the history
  • Loading branch information
navedqb authored Aug 8, 2024
1 parent f3a7610 commit 7fb24b0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion components/lib/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import PrimeReact, { PrimeReactContext, localeOption, localeOptions } from '../api/Api';
import { Button } from '../button/Button';
import { useHandleStyle } from '../componentbase/ComponentBase';
import { useMergeProps, useMountEffect, useOverlayListener, usePrevious, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
import { useMergeProps, useMountEffect, useOverlayListener, usePrevious, useUnmountEffect, useUpdateEffect, useGlobalOnEscapeKey, ESC_KEY_HANDLING_PRIORITIES } from '../hooks/Hooks';
import { CalendarIcon } from '../icons/calendar';
import { ChevronDownIcon } from '../icons/chevrondown';
import { ChevronLeftIcon } from '../icons/chevronleft';
Expand Down Expand Up @@ -35,6 +35,14 @@ export const Calendar = React.memo(
};
const { ptm, cx, isUnstyled } = CalendarBase.setMetaData(metaData);

useGlobalOnEscapeKey({
callback: () => {
hide();
},
when: overlayVisibleState,
priority: [ESC_KEY_HANDLING_PRIORITIES.OVERLAY_PANEL, 0]
});

useHandleStyle(CalendarBase.css.styles, isUnstyled, { name: 'calendar' });
const elementRef = React.useRef(null);
const overlayRef = React.useRef(null);
Expand Down

0 comments on commit 7fb24b0

Please sign in to comment.