Hotfix (logically) nested multiActions
This commit is contained in:
parent
04f6f89ada
commit
4d6fc24b40
@ -149,7 +149,7 @@
|
|||||||
var INTERACTIVE_FIELDSET_UTIL_TARGET_SELECTOR = '.interactive-fieldset--target';
|
var INTERACTIVE_FIELDSET_UTIL_TARGET_SELECTOR = '.interactive-fieldset--target';
|
||||||
|
|
||||||
var INTERACTIVE_FIELDSET_INITIALIZED_CLASS = 'interactive-fieldset--initialized';
|
var INTERACTIVE_FIELDSET_INITIALIZED_CLASS = 'interactive-fieldset--initialized';
|
||||||
var INTERACTIVE_FIELDSET_CHILD_SELECTOR = 'input:not([disabled])';
|
var INTERACTIVE_FIELDSET_CHILD_SELECTOR = 'input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled])';
|
||||||
|
|
||||||
var interactiveFieldsetUtil = function(element) {
|
var interactiveFieldsetUtil = function(element) {
|
||||||
var conditionalInput;
|
var conditionalInput;
|
||||||
@ -195,6 +195,10 @@
|
|||||||
childInputs = Array.from(element.querySelectorAll(INTERACTIVE_FIELDSET_CHILD_SELECTOR));
|
childInputs = Array.from(element.querySelectorAll(INTERACTIVE_FIELDSET_CHILD_SELECTOR));
|
||||||
|
|
||||||
// add event listener
|
// add event listener
|
||||||
|
var observer = new MutationObserver(function(mutationsList, observer) {
|
||||||
|
updateVisibility();
|
||||||
|
});
|
||||||
|
observer.observe(conditionalInput, { attributes: true, attributeFilter: ['disabled'] });
|
||||||
conditionalInput.addEventListener('input', updateVisibility);
|
conditionalInput.addEventListener('input', updateVisibility);
|
||||||
|
|
||||||
// initial visibility update
|
// initial visibility update
|
||||||
@ -211,12 +215,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateVisibility() {
|
function updateVisibility() {
|
||||||
var active = matchesConditionalValue();
|
var active = matchesConditionalValue() && !conditionalInput.disabled;
|
||||||
|
|
||||||
target.classList.toggle('hidden', !active);
|
target.classList.toggle('hidden', !active);
|
||||||
|
|
||||||
childInputs.forEach(function(el) {
|
childInputs.forEach(function(el) {
|
||||||
el.toggleAttribute('disabled', !active);
|
el.disabled = !active;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user