From 3b6e3193ae5e6248ad1405de50a98fb41796bc2e Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 27 Sep 2020 11:47:56 -0400 Subject: [PATCH] Fix data-setting attributes not being updated on index change (#872) --- ext/bg/js/settings/scan-inputs-controller.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ext/bg/js/settings/scan-inputs-controller.js b/ext/bg/js/settings/scan-inputs-controller.js index 0606d142..5da0d5e1 100644 --- a/ext/bg/js/settings/scan-inputs-controller.js +++ b/ext/bg/js/settings/scan-inputs-controller.js @@ -135,6 +135,7 @@ class ScanInputField { set index(value) { this._index = value; + this._updateDataSettingTargets(); } prepare(container, include, exclude) { @@ -158,10 +159,7 @@ class ScanInputField { this._eventListeners.on(this._excludeInputField, 'change', this._onExcludeValueChange.bind(this)); this._eventListeners.addEventListener(removeButton, 'click', this._onRemoveClick.bind(this)); - for (const typeCheckbox of node.querySelectorAll('.scan-input-settings-checkbox')) { - const {property} = typeCheckbox.dataset; - typeCheckbox.dataset.setting = `scanning.inputs[${this._index}].${property}`; - } + this._updateDataSettingTargets(); } cleanup() { @@ -201,4 +199,12 @@ class ScanInputField { const node = this._node.querySelector(`input.scan-input-settings-checkbox[data-property="types.${pointerType}"]`); return node !== null && node.checked; } + + _updateDataSettingTargets() { + const index = this._index; + for (const typeCheckbox of this._node.querySelectorAll('.scan-input-settings-checkbox')) { + const {property} = typeCheckbox.dataset; + typeCheckbox.dataset.setting = `scanning.inputs[${index}].${property}`; + } + } }