fix ReactModal bodyOpenClassName error so that it is entirely omitted, rather than passing null value (#2176)

This commit is contained in:
Benjamin Wheeler 2018-10-11 16:58:30 -04:00 committed by GitHub
parent 1f8342b987
commit d5343dfb01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,14 +23,15 @@ class Modal extends React.Component {
return this.modal.portal.requestClose();
}
render () {
// bodyOpenClassName prop cannot be blank string or null here; both cause
// an error, because ReactModal does not correctly handle them.
// If we're not setting it to a class name, we must omit the prop entirely.
const bodyOpenClassNameProp = this.props.useStandardSizes ?
{bodyOpenClassName: classNames('overflow-hidden')} : {};
return (
<ReactModal
appElement={document.getElementById('app')}
// bodyOpenClassName can be blank string, but must not be null here; a null value causes
// an error, because ReactModal does not correctly handle the case of a null bodyOpenClassName
bodyOpenClassName={classNames({
'overflow-hidden': this.props.useStandardSizes
})}
{...bodyOpenClassNameProp}
className={{
base: classNames('modal-content', this.props.className, {
'modal-sizes': this.props.useStandardSizes