From 99d79e75719ed9cdc4850721a3007c8ad7b74efa Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Fri, 7 Aug 2020 15:59:00 -0400 Subject: [PATCH] update: Modal --- js/src/common/components/Modal.js | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/js/src/common/components/Modal.js b/js/src/common/components/Modal.js index 637a100d9..d1a5adc77 100644 --- a/js/src/common/components/Modal.js +++ b/js/src/common/components/Modal.js @@ -14,7 +14,7 @@ export default class Modal extends Component { */ static isDismissible = true; - init() { + oninit() { /** * Attributes for an alert component to show below the header. * @@ -23,17 +23,11 @@ export default class Modal extends Component { this.alertAttrs = null; } - config(isInitialized, context) { - if (isInitialized) return; - - this.props.onshow(() => this.onready()); - - context.onunload = () => { - this.props.onhide(); - }; + oncreate(vnode) { + vnode.attrs.onshow(() => this.onready(vnode.attrs)); } - view() { + view(vnode) { if (this.alertAttrs) { this.alertAttrs.dismissible = false; } @@ -45,7 +39,7 @@ export default class Modal extends Component {
{Button.component({ icon: 'fas fa-times', - onclick: this.hide.bind(this), + onclick: this.hide.bind(this, vnode.attrs), className: 'Button Button--icon Button--link', })}
@@ -60,7 +54,7 @@ export default class Modal extends Component { {this.alertAttrs ?
{Alert.component(this.alertAttrs)}
: ''} - {this.content()} + {this.content(vnode.attrs)} @@ -89,7 +83,7 @@ export default class Modal extends Component { * @return {VirtualElement} * @abstract */ - content() {} + content(attrs) {} /** * Handle the modal form's submit event. @@ -101,15 +95,15 @@ export default class Modal extends Component { /** * Focus on the first input when the modal is ready to be used. */ - onready() { + onready(attrs) { this.$('form').find('input, select, textarea').first().focus().select(); } /** * Hide the modal. */ - hide() { - this.props.onhide(); + hide(attrs) { + attrs.onhide(); } /**