mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 17:15:48 +00:00
nested modals issue fixed
This commit is contained in:
parent
d396d9038b
commit
90fd16edcd
3 changed files with 16 additions and 22 deletions
|
|
@ -1,31 +1,27 @@
|
|||
import React, { PureComponent } from 'react';
|
||||
import { PureComponent } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import ReactDOM from 'react-dom';
|
||||
import classnames from 'classnames';
|
||||
import styles from './styles';
|
||||
|
||||
class Modal extends PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.root = document.createElement('div');
|
||||
this.modalElement = document.createElement('div');
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
document.body.appendChild(this.root);
|
||||
componentWillMount() {
|
||||
document.body.appendChild(this.modalElement);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
document.body.removeChild(this.root);
|
||||
document.body.removeChild(this.modalElement);
|
||||
}
|
||||
|
||||
render() {
|
||||
return ReactDOM.createPortal(
|
||||
<div className={classnames(styles['modal-container'], this.props.className)} onClick={this.props.onRequestClose}>
|
||||
{this.props.children}
|
||||
</div>,
|
||||
this.root
|
||||
);
|
||||
this.modalElement.className = classnames('modal-container', this.props.className);
|
||||
this.modalElement.onclick = this.props.onRequestClose;
|
||||
return ReactDOM.createPortal(this.props.children, this.modalElement);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
.modal-container {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
min-width: 1024px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
|
@ -96,7 +96,7 @@
|
|||
font-weight: normal;
|
||||
}
|
||||
|
||||
html, body, #app {
|
||||
html, body, #app, .modal-container {
|
||||
position: relative;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
|
|
@ -106,6 +106,13 @@
|
|||
font: 13px / 18px 'Open Sans', 'LatoLight', 'Arial', 'Helvetica', 'sans-serif';
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.modal-container {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue