From b74de0f88df511b8d3c47890829d7a06ced8766e Mon Sep 17 00:00:00 2001 From: Felix Hamann Date: Sun, 21 Apr 2019 17:22:22 +0200 Subject: [PATCH] reintroduce explicit interactive fieldset target but keep it optional --- static/js/utils/form.js | 8 +++++--- templates/widgets/aform/aform.hamlet | 2 +- templates/widgets/communication/recipientLayout.hamlet | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/static/js/utils/form.js b/static/js/utils/form.js index 7a949c539..a68f56b9f 100644 --- a/static/js/utils/form.js +++ b/static/js/utils/form.js @@ -146,7 +146,7 @@ var INTERACTIVE_FIELDSET_UTIL_NAME = 'interactiveFieldset'; var INTERACTIVE_FIELDSET_UTIL_SELECTOR = '[uw-interactive-fieldset]'; - 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_CHILD_SELECTOR = 'input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled])'; @@ -182,8 +182,10 @@ } conditionalValue = element.dataset.conditionalValue; - // check if there is a target ancestor, otherwise target the fieldset itself - target = element.closest(INTERACTIVE_FIELDSET_UTIL_TARGET_SELECTOR) || element; + target = element.closest(INTERACTIVE_FIELDSET_UTIL_TARGET_SELECTOR); + if (!target || element.matches(INTERACTIVE_FIELDSET_UTIL_TARGET_SELECTOR)) { + target = element; + } childInputs = Array.from(element.querySelectorAll(INTERACTIVE_FIELDSET_CHILD_SELECTOR)); diff --git a/templates/widgets/aform/aform.hamlet b/templates/widgets/aform/aform.hamlet index 91ebc2b93..460ca1ba7 100644 --- a/templates/widgets/aform/aform.hamlet +++ b/templates/widgets/aform/aform.hamlet @@ -11,7 +11,7 @@ $case formLayout

^{fvLabel view} $else -
+
$if not (Blaze.null $ fvLabel view)