make target for interactive-fieldset optional
This commit is contained in:
parent
721630f4b2
commit
b35dc87db6
@ -182,15 +182,8 @@
|
||||
}
|
||||
conditionalValue = element.dataset.conditionalValue;
|
||||
|
||||
if (element.matches(INTERACTIVE_FIELDSET_UTIL_TARGET_SELECTOR)) {
|
||||
target = element;
|
||||
}
|
||||
if (!target) {
|
||||
target = element.closest(INTERACTIVE_FIELDSET_UTIL_TARGET_SELECTOR);
|
||||
}
|
||||
if (!target) {
|
||||
throw new Error('Interactive Fieldset needs to be a target or have a target-ancestor!');
|
||||
}
|
||||
// check if there is a target ancestor, otherwise target the fieldset itself
|
||||
target = element.closest(INTERACTIVE_FIELDSET_UTIL_TARGET_SELECTOR) || element;
|
||||
|
||||
childInputs = Array.from(element.querySelectorAll(INTERACTIVE_FIELDSET_CHILD_SELECTOR));
|
||||
|
||||
@ -212,7 +205,7 @@
|
||||
|
||||
function updateVisibility() {
|
||||
var active = matchesConditionalValue();
|
||||
|
||||
|
||||
target.classList.toggle('hidden', !active);
|
||||
|
||||
childInputs.forEach(function(el) {
|
||||
|
||||
@ -11,7 +11,7 @@ $case formLayout
|
||||
<h3 .form-section-title>
|
||||
^{fvLabel view}
|
||||
$else
|
||||
<div .form-group .interactive-fieldset--target :fvRequired view:.form-group--required :not $ fvRequired view:.form-group--optional :isJust $ fvErrors view:.form-group--has-error>
|
||||
<div .form-group :fvRequired view:.form-group--required :not $ fvRequired view:.form-group--optional :isJust $ fvErrors view:.form-group--has-error>
|
||||
$if not (Blaze.null $ fvLabel view)
|
||||
<label .form-group-label for=#{fvId view}>
|
||||
<span .form-group-label__caption>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user