From a50ede7967e3ee33f5ad47900298a31c25c083a8 Mon Sep 17 00:00:00 2001 From: nathangray Date: Mon, 29 Jun 2020 10:54:14 -0600 Subject: [PATCH] Avoid errors from close confirm changes if button is not fully created. --- api/js/etemplate/et2_widget_button.js | 5 +++-- api/js/etemplate/et2_widget_button.ts | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/api/js/etemplate/et2_widget_button.js b/api/js/etemplate/et2_widget_button.js index 707795bc56..fc22d9c69d 100644 --- a/api/js/etemplate/et2_widget_button.js +++ b/api/js/etemplate/et2_widget_button.js @@ -195,12 +195,13 @@ var et2_button = /** @class */ (function (_super) { * @returns {Boolean} */ et2_button.prototype.click = function (_ev) { + var _a, _b; // ignore click on readonly button if (this.options.readonly) return false; this.clicked = true; // Cancel buttons don't trigger the close confirmation prompt - if (this.btn.hasClass("et2_button_cancel")) { + if ((_a = this.btn) === null || _a === void 0 ? void 0 : _a.hasClass("et2_button_cancel")) { this.getInstanceManager().skip_close_prompt(); } if (!_super.prototype.click.apply(this, arguments)) { @@ -212,7 +213,7 @@ var et2_button = /** @class */ (function (_super) { this.getInstanceManager().submit(this, false, this.options.novalidate); //TODO: this only needs to be passed if it's in a datagrid } this.clicked = false; - this.getInstanceManager().skip_close_prompt(false); + (_b = this.getInstanceManager()) === null || _b === void 0 ? void 0 : _b.skip_close_prompt(false); return true; }; et2_button.prototype.set_label = function (_value) { diff --git a/api/js/etemplate/et2_widget_button.ts b/api/js/etemplate/et2_widget_button.ts index 98e28acef0..9fd9cc49f3 100644 --- a/api/js/etemplate/et2_widget_button.ts +++ b/api/js/etemplate/et2_widget_button.ts @@ -311,7 +311,7 @@ export class et2_button extends et2_baseWidget implements et2_IInput, et2_IDetac this.clicked = true; // Cancel buttons don't trigger the close confirmation prompt - if(this.btn.hasClass("et2_button_cancel")) + if(this.btn?.hasClass("et2_button_cancel")) { this.getInstanceManager().skip_close_prompt(); } @@ -328,7 +328,7 @@ export class et2_button extends et2_baseWidget implements et2_IInput, et2_IDetac this.getInstanceManager().submit(this, false, this.options.novalidate); //TODO: this only needs to be passed if it's in a datagrid } this.clicked = false; - this.getInstanceManager().skip_close_prompt(false); + this.getInstanceManager()?.skip_close_prompt(false); return true; }