mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 08:25:44 +01:00
add extra root for modals and use it
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
// @flow
|
// @flow
|
||||||
//modified from https://github.com/GA-MO/react-confirm-alert
|
|
||||||
|
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { render, unmountComponentAtNode } from "react-dom";
|
import ReactDOM from "react-dom";
|
||||||
import "./ConfirmAlert.css";
|
import "./ConfirmAlert.css";
|
||||||
|
|
||||||
type Button = {
|
type Button = {
|
||||||
@@ -25,7 +23,7 @@ class ConfirmAlert extends React.Component<Props> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
close = () => {
|
close = () => {
|
||||||
removeElementReconfirm();
|
ReactDOM.unmountComponentAtNode(document.getElementById("modalRoot"));
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@@ -67,27 +65,11 @@ class ConfirmAlert extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createElementReconfirm(properties: Props) {
|
|
||||||
const divTarget = document.createElement("div");
|
|
||||||
divTarget.id = "react-confirm-alert";
|
|
||||||
if (document.body) {
|
|
||||||
document.body.appendChild(divTarget);
|
|
||||||
render(<ConfirmAlert {...properties} />, divTarget);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeElementReconfirm() {
|
|
||||||
const target = document.getElementById("react-confirm-alert");
|
|
||||||
if (target) {
|
|
||||||
unmountComponentAtNode(target);
|
|
||||||
if (target.parentNode) {
|
|
||||||
target.parentNode.removeChild(target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function confirmAlert(properties: Props) {
|
export function confirmAlert(properties: Props) {
|
||||||
createElementReconfirm(properties);
|
const root = document.getElementById("modalRoot");
|
||||||
|
if(root){
|
||||||
|
ReactDOM.render(<ConfirmAlert {...properties}/>, root);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ConfirmAlert;
|
export default ConfirmAlert;
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
You need to enable JavaScript to run this app.
|
You need to enable JavaScript to run this app.
|
||||||
</noscript>
|
</noscript>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
<div id="modalRoot"></div>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
This HTML file is a template.
|
This HTML file is a template.
|
||||||
If you open it directly in the browser, you will see an empty page.
|
If you open it directly in the browser, you will see an empty page.
|
||||||
|
|||||||
Reference in New Issue
Block a user