From 713c0ce21b01e8fca7b9b733cfe3fa9fb6f0ce2c Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 6 Apr 2023 16:13:00 -0600 Subject: [PATCH] Et2Dialog: Move enter handler to keyUp so input event handlers can fire first --- api/js/etemplate/Et2Dialog/Et2Dialog.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/api/js/etemplate/Et2Dialog/Et2Dialog.ts b/api/js/etemplate/Et2Dialog/Et2Dialog.ts index 524b8c0a02..b261756f71 100644 --- a/api/js/etemplate/Et2Dialog/Et2Dialog.ts +++ b/api/js/etemplate/Et2Dialog/Et2Dialog.ts @@ -400,7 +400,7 @@ export class Et2Dialog extends Et2Widget(SlotMixin(SlDialog)) this._onClick = this._onClick.bind(this); this._onButtonClick = this._onButtonClick.bind(this); this._onMoveResize = this._onMoveResize.bind(this); - this.handleKeyDown = this.handleKeyDown.bind(this); + this.handleKeyUp = this.handleKeyUp.bind(this); this._adoptTemplateButtons = this._adoptTemplateButtons.bind(this); // Don't leave it undefined, it's easier to deal with if it's just already resolved. @@ -419,6 +419,8 @@ export class Et2Dialog extends Et2Widget(SlotMixin(SlDialog)) { super.connectedCallback(); + this.addEventListener("keyup", this.handleKeyUp); + // Prevent close if they click the overlay when the dialog is modal this.addEventListener('sl-request-close', event => { @@ -436,6 +438,7 @@ export class Et2Dialog extends Et2Widget(SlotMixin(SlDialog)) disconnectedCallback() { super.disconnectedCallback(); + this.removeEventListener("keyup", this.handleKeyUp); this.removeEventListener("sl-hide", this.handleClose); this.removeEventListener("sl-after-show", this.handleOpen); } @@ -476,11 +479,8 @@ export class Et2Dialog extends Et2Widget(SlotMixin(SlDialog)) this.removeEventListener("keydown", this.handleKeyDown); } - handleKeyDown(event : KeyboardEvent) + handleKeyUp(event : KeyboardEvent) { - // Parent handles escape, but is already bound - super.handleKeyDown(event); - // Trigger the "primary" or first button if(this.open && event.key === 'Enter') {