mirror of
https://github.com/flarum/core.git
synced 2025-08-05 07:57:46 +02:00
Fix ModalManager not allowing vnodes, make modals set themselves to app.modal.component when created
This commit is contained in:
@@ -2,6 +2,7 @@ import MicroModal from 'micromodal';
|
|||||||
|
|
||||||
import Component from '../Component';
|
import Component from '../Component';
|
||||||
import Modal from './Modal';
|
import Modal from './Modal';
|
||||||
|
import {Vnode} from "mithril";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The `ModalManager` component manages a modal dialog. Only one modal dialog
|
* The `ModalManager` component manages a modal dialog. Only one modal dialog
|
||||||
@@ -9,9 +10,11 @@ import Modal from './Modal';
|
|||||||
* overwrite the previous one.
|
* overwrite the previous one.
|
||||||
*/
|
*/
|
||||||
export default class ModalManager extends Component {
|
export default class ModalManager extends Component {
|
||||||
|
private node: Vnode;
|
||||||
|
|
||||||
showing: boolean;
|
showing: boolean;
|
||||||
component: Modal;
|
|
||||||
hideTimeout: number;
|
hideTimeout: number;
|
||||||
|
component?: Modal;
|
||||||
|
|
||||||
oncreate(vnode) {
|
oncreate(vnode) {
|
||||||
super.oncreate(vnode);
|
super.oncreate(vnode);
|
||||||
@@ -22,7 +25,7 @@ export default class ModalManager extends Component {
|
|||||||
view() {
|
view() {
|
||||||
return (
|
return (
|
||||||
<div className="ModalManager modal" id="Modal" onclick={this.onclick.bind(this)} key="modal">
|
<div className="ModalManager modal" id="Modal" onclick={this.onclick.bind(this)} key="modal">
|
||||||
{this.component && m(this.component)}
|
{this.node}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -30,15 +33,15 @@ export default class ModalManager extends Component {
|
|||||||
/**
|
/**
|
||||||
* Show a modal dialog.
|
* Show a modal dialog.
|
||||||
*/
|
*/
|
||||||
show(component: Modal) {
|
show(component) {
|
||||||
if (!(component instanceof Modal)) {
|
if (!(component instanceof Modal) && !(component.tag?.prototype instanceof Modal)) {
|
||||||
throw new Error('The ModalManager component can only show Modal components');
|
throw new Error('The ModalManager component can only show Modal components');
|
||||||
}
|
}
|
||||||
|
|
||||||
clearTimeout(this.hideTimeout);
|
clearTimeout(this.hideTimeout);
|
||||||
|
|
||||||
this.showing = true;
|
this.showing = true;
|
||||||
this.component = component;
|
this.node = component.tag ? component : m(component);
|
||||||
|
|
||||||
// if (app.current) app.current.retain = true;
|
// if (app.current) app.current.retain = true;
|
||||||
|
|
||||||
@@ -95,7 +98,7 @@ export default class ModalManager extends Component {
|
|||||||
|
|
||||||
this.component = null;
|
this.component = null;
|
||||||
|
|
||||||
app.current.retain = false;
|
// app.current.retain = false;
|
||||||
|
|
||||||
m.redraw();
|
m.redraw();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user