From 41cf0bedfcccfdb96a0d2950901ac10d737c47e6 Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 27 Sep 2023 16:24:12 +1000 Subject: [PATCH] Fix: Handle missing attributes --- app/webpacker/controllers/bulk_form_controller.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/webpacker/controllers/bulk_form_controller.js b/app/webpacker/controllers/bulk_form_controller.js index 842a1aaa89..702d882d09 100644 --- a/app/webpacker/controllers/bulk_form_controller.js +++ b/app/webpacker/controllers/bulk_form_controller.js @@ -52,7 +52,7 @@ export default class BulkFormController extends Controller { this.#disableOtherElements(formChanged); // like filters and sorting // Display number of records changed - const key = this.changedSummaryTarget && this.changedSummaryTarget.dataset.translationKey; + const key = this.hasChangedSummaryTarget && this.changedSummaryTarget.dataset.translationKey; if (key) { this.changedSummaryTarget.textContent = I18n.t(key, { count: changedRecordCount }); } @@ -76,13 +76,15 @@ export default class BulkFormController extends Controller { // private #disableOtherElements(disable) { + if (!this.hasDisableSelectorValue) return; + this.disableElements ||= document.querySelectorAll(this.disableSelectorValue); - if (this.disableElements) { - this.disableElements.forEach((element) => { - element.classList.toggle("disabled-section", disable); - }); - } + if (!this.disableElements) return; + + this.disableElements.forEach((element) => { + element.classList.toggle("disabled-section", disable); + }); } #isChanged(element) {