diff --git a/components/lib/blockui/BlockUI.js b/components/lib/blockui/BlockUI.js index 3017dc1c07..e5872a593d 100644 --- a/components/lib/blockui/BlockUI.js +++ b/components/lib/blockui/BlockUI.js @@ -28,28 +28,29 @@ export const BlockUI = React.forwardRef((inProps, ref) => { }; const unblock = () => { - const callback = () => { - setVisibleState(false); + !isUnstyled() && DomHandler.addClass(maskRef.current, 'p-component-overlay-leave'); - if (props.fullScreen) { - DomHandler.unblockBodyScroll(); - activeElementRef.current && activeElementRef.current.focus(); - } - - props.onUnblocked && props.onUnblocked(); - }; - - if (maskRef.current) { - DomHandler.addClass(maskRef.current, 'p-component-overlay-leave'); + if (DomHandler.hasCSSAnimation(maskRef.current) > 0) { maskRef.current.addEventListener('animationend', () => { - ZIndexUtils.clear(maskRef.current); - callback(); + removeMask(); }); } else { - callback(); + removeMask(); } }; + const removeMask = () => { + ZIndexUtils.clear(maskRef.current); + setVisibleState(false); + + if (props.fullScreen) { + DomHandler.unblockBodyScroll(); + activeElementRef.current && activeElementRef.current.focus(); + } + + props.onUnblocked && props.onUnblocked(); + }; + const onPortalMounted = () => { if (props.fullScreen) { DomHandler.blockBodyScroll(); diff --git a/components/lib/blockui/__snapshots__/BlockUI.spec.js.snap b/components/lib/blockui/__snapshots__/BlockUI.spec.js.snap index cf60a1da34..68a1a53851 100644 --- a/components/lib/blockui/__snapshots__/BlockUI.spec.js.snap +++ b/components/lib/blockui/__snapshots__/BlockUI.spec.js.snap @@ -16,15 +16,15 @@ exports[`BlockUI block and unblock fullscreen events: blocked-event-fullscreen 1