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