From 95bcd603f5d51942d52c3bec54a254da4d4eff2c Mon Sep 17 00:00:00 2001 From: melloware Date: Wed, 27 Jul 2022 11:21:30 -0400 Subject: [PATCH] Fix #3111: Calendar TouchUI modality issues --- components/lib/calendar/Calendar.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/components/lib/calendar/Calendar.js b/components/lib/calendar/Calendar.js index a286c2fea3..73388d6236 100644 --- a/components/lib/calendar/Calendar.js +++ b/components/lib/calendar/Calendar.js @@ -1442,6 +1442,8 @@ export const Calendar = React.memo(React.forwardRef((props, ref) => { overlayEventListener.current = null; }; + props.touchUI && disableModality(); + if (props.onVisibleChange) { props.onVisibleChange({ visible: false, @@ -1516,6 +1518,7 @@ export const Calendar = React.memo(React.forwardRef((props, ref) => { touchUIMaskClickListener.current = () => { disableModality(); + hide(); }; touchUIMask.current.addEventListener('click', touchUIMaskClickListener.current); @@ -1534,10 +1537,12 @@ export const Calendar = React.memo(React.forwardRef((props, ref) => { } const destroyMask = () => { - touchUIMask.current.removeEventListener('click', touchUIMaskClickListener.current); - touchUIMaskClickListener.current = null; - document.body.removeChild(touchUIMask.current); - touchUIMask.current = null; + if (touchUIMask.current) { + touchUIMask.current.removeEventListener('click', touchUIMaskClickListener.current); + touchUIMaskClickListener.current = null; + document.body.removeChild(touchUIMask.current); + touchUIMask.current = null; + } let bodyChildren = document.body.children; let hasBlockerMasks;