diff --git a/change-log.txt b/change-log.txt index 7b0af1a..ae8c4b1 100644 --- a/change-log.txt +++ b/change-log.txt @@ -1,3 +1,6 @@ += 0.2.22 - TBD = +* Conditional field don't reset field value on hide element - FIXED + = 0.2.21 - 2024-07-31 = * JS error on FSE theme edit template part page - FIXED diff --git a/includes/ayecode-ui-settings.php b/includes/ayecode-ui-settings.php index c6fece1..de8bf72 100644 --- a/includes/ayecode-ui-settings.php +++ b/includes/ayecode-ui-settings.php @@ -3050,16 +3050,22 @@ function aui_cf_field_apply_action($el, rule, isTrue) { var $destEl = jQuery('[data-rule-key="' + rule.key + '"]'); if (rule.action === 'show' && isTrue) { - if ($destEl.is(':hidden')) { + if ($destEl.is(':hidden') && !$destEl.hasClass('aui-cf-skip-reset')) { aui_cf_field_reset_default_value($destEl); } aui_cf_field_show_element($destEl); } else if (rule.action === 'show' && !isTrue) { + if (!$destEl.is(':hidden') && !$destEl.hasClass('aui-cf-skip-reset')) { + aui_cf_field_reset_default_value($destEl); + } aui_cf_field_hide_element($destEl); } else if (rule.action === 'hide' && isTrue) { + if (!$destEl.is(':hidden') && !$destEl.hasClass('aui-cf-skip-reset')) { + aui_cf_field_reset_default_value($destEl); + } aui_cf_field_hide_element($destEl); } else if (rule.action === 'hide' && !isTrue) { - if ($destEl.is(':hidden')) { + if ($destEl.is(':hidden') && !$destEl.hasClass('aui-cf-skip-reset')) { aui_cf_field_reset_default_value($destEl); } aui_cf_field_show_element($destEl);