From 1178d16afda26825561a3361b83cc2a091a3003f Mon Sep 17 00:00:00 2001 From: nathan Date: Fri, 30 Jun 2023 11:01:22 -0600 Subject: [PATCH] Et2Dialog fixes - Fix noCloseButton attribute was not implemented - Fix hideOnExcape=false still allowed closing on escape - Fix using Et2Dialog.BUTTONS_OK showed no buttons --- api/js/etemplate/Et2Dialog/Et2Dialog.ts | 26 +++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/api/js/etemplate/Et2Dialog/Et2Dialog.ts b/api/js/etemplate/Et2Dialog/Et2Dialog.ts index 035f41cc5c..2c96c2db55 100644 --- a/api/js/etemplate/Et2Dialog/Et2Dialog.ts +++ b/api/js/etemplate/Et2Dialog/Et2Dialog.ts @@ -235,14 +235,23 @@ export class Et2Dialog extends Et2Widget(SlotMixin(SlDialog)) /* Non-modal dialogs don't have an overlay */ - :host(:not([isModal])) .dialog, :host(:not([isModal])) .dialog__overlay { + :host(:not([ismodal])) .dialog, :host(:not([isModal])) .dialog__overlay { pointer-events: none; background: transparent; } - :host(:not([isModal])) .dialog__panel { + + :host(:not([ismodal])) .dialog__panel { pointer-events: auto; } + /* Hide close button when set */ + + :host([noclosebutton]) .dialog__close { + display: none; + } + + /* Button alignments */ + ::slotted([align="left"]) { margin-right: auto; order: -1; @@ -311,7 +320,7 @@ export class Et2Dialog extends Et2Widget(SlotMixin(SlDialog)) /** * When set to true it removes the close button from dialog's header */ - noCloseButton: Boolean + noCloseButton: {type: Boolean, reflect: true} } } @@ -424,9 +433,17 @@ export class Et2Dialog extends Et2Widget(SlotMixin(SlDialog)) // Prevent close if they click the overlay when the dialog is modal this.addEventListener('sl-request-close', event => { + // Prevent close on clicking somewhere else if(this.isModal && event.detail.source === 'overlay') { event.preventDefault(); + return; + } + // Prevent close on escape + if(!this.hideOnEscape && event.detail.source === 'keyboard') + { + event.preventDefault(); + return; } }) @@ -876,7 +893,8 @@ export class Et2Dialog extends Et2Widget(SlotMixin(SlDialog)) _buttonsTemplate() { - if(!this.buttons) + // No buttons set, but careful with BUTTONS_OK + if(!this.buttons && this.buttons !== Et2Dialog.BUTTONS_OK) { return; }