Skip to content

Commit

Permalink
Added type option to listener, Updated the calendar listener
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrogenous committed Mar 11, 2024
1 parent 50689b5 commit 24d5fe9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion components/lib/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ export const Calendar = React.memo(

isOverlayClicked.current = false;
},
when: !(props.touchUI || props.inline) && visible
when: !(props.touchUI || props.inline) && visible,
type: 'mousedown'
});

const getDateFormat = () => {
Expand Down
4 changes: 2 additions & 2 deletions components/lib/hooks/useOverlayListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useOverlayScrollListener } from './useOverlayScrollListener';
import { useResizeListener } from './useResizeListener';
import { useUnmountEffect } from './useUnmountEffect';

export const useOverlayListener = ({ target, overlay, listener, when = true }) => {
export const useOverlayListener = ({ target, overlay, listener, when = true, type = 'click' }) => {
const targetRef = React.useRef(null);
const overlayRef = React.useRef(null);

Expand All @@ -18,7 +18,7 @@ export const useOverlayListener = ({ target, overlay, listener, when = true }) =
*/
const [bindDocumentClickListener, unbindDocumentClickListener] = useEventListener({
target: 'window',
type: 'click',
type: type,
listener: (event) => {
listener && listener(event, { type: 'outside', valid: event.which !== 3 && isOutsideClicked(event) });
}
Expand Down

0 comments on commit 24d5fe9

Please sign in to comment.