-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: POC for isHidden prop on ModalDialog #2431
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ | |
* component is that if a modal object is visible then it is "enabled" | ||
*/ | ||
function ModalLayer({ | ||
children, onClose, isOpen, isBlocking, zIndex, | ||
children, onClose, isOpen, isHidden, isBlocking, zIndex, | ||
}) { | ||
useEffect(() => { | ||
if (isOpen) { | ||
|
@@ -52,29 +52,31 @@ | |
}; | ||
}, [isOpen]); | ||
|
||
if (!isOpen) { | ||
if (!isOpen && !isHidden) { | ||
return null; | ||
} | ||
|
||
const onClickOutside = !isBlocking ? onClose : null; | ||
|
||
return ( | ||
<ModalContextProvider onClose={onClose} isOpen={isOpen} isBlocking={isBlocking}> | ||
<ModalContextProvider onClose={onClose} isOpen={isOpen} isHidden={isHidden} isBlocking={isBlocking}> | ||
<Portal> | ||
<FocusOn | ||
allowPinchZoom | ||
scrollLock | ||
enabled={isOpen} | ||
enabled={isOpen && !isHidden} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
onEscapeKey={onClose} | ||
onClickOutside={onClickOutside} | ||
className={classNames( | ||
'pgn__modal-layer', | ||
zIndex ? `zindex-${zIndex}` : '', | ||
)} | ||
className={classNames({ | ||
'pgn__modal-layer': isOpen && !isHidden, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [inform] Conditionally include the |
||
[`zindex-${zIndex}`]: !!zIndex, | ||
})} | ||
> | ||
<ModalContentContainer> | ||
<ModalBackdrop onClick={onClickOutside} /> | ||
{children} | ||
{!isHidden && <ModalBackdrop onClick={onClickOutside} />} | ||
<div className={classNames({ 'd-none': isHidden })}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: we should avoid using CSS utility classes with |
||
{children} | ||
</div> | ||
</ModalContentContainer> | ||
</FocusOn> | ||
</Portal> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[consideration] It's possible this conditional could remain unchanged given
isOpen
would need to be truthy forisHidden
to work anyways.