From 6062200a6fbafa369377095b7a5657dfdbde12f2 Mon Sep 17 00:00:00 2001 From: pid18718 Date: Wed, 19 Nov 2025 10:49:25 +0100 Subject: [PATCH 1/5] =?UTF-8?q?SITES-35060=20Title=20Component=20Policy=20?= =?UTF-8?q?Dialog=20Throws=20False=20=E2=80=9CSelect=20at=20least=20one=20?= =?UTF-8?q?size=20option=E2=80=9D=20Error=20(SDK=202025.4+)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v2/title/clientlibs/editor/js/title.js | 73 ++++++++++++------- 1 file changed, 47 insertions(+), 26 deletions(-) diff --git a/content/src/content/jcr_root/apps/core/wcm/components/title/v2/title/clientlibs/editor/js/title.js b/content/src/content/jcr_root/apps/core/wcm/components/title/v2/title/clientlibs/editor/js/title.js index 5de569534d..5bf4567369 100644 --- a/content/src/content/jcr_root/apps/core/wcm/components/title/v2/title/clientlibs/editor/js/title.js +++ b/content/src/content/jcr_root/apps/core/wcm/components/title/v2/title/clientlibs/editor/js/title.js @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2017 Adobe + * Copyright 2017 Adobe Systems Incorporated * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,6 +42,7 @@ var select = $(DEFAULT_SIZE_SELECTOR).get(0); var $checkboxes = $(ALLOWED_SIZES_SELECTOR); var checkedTotal = 0; + var firstCheckedValue = ""; var selectValue = ""; if (select === null || select === undefined) { @@ -62,9 +63,18 @@ } }); + // get the value of the first checked box + $checkboxes.each(function(i, checkbox) { + if (checkbox.checked) { + firstCheckedValue = checkbox.value; + return false; + } + }); + // set the default value of the size dropdown if (checkboxToggled) { - selectValue = getAppropriateCheckedBoxValue($checkboxes, select.value); + // the default value is the first checked box + selectValue = firstCheckedValue; } else { // the default value is read from the repository selectValue = select.value; @@ -134,7 +144,21 @@ // Update the default size select when an allowed size is checked/unchecked $document.on("change", ALLOWED_SIZES_SELECTOR, function(e) { + // update default size dropdown as before updateDefaultSizeSelect(true); + + // re-validate all Allowed Types / Sizes checkboxes in this group + var $checkboxes = $(this) + .closest(".core-title-sizes-allowed") + .find(ALLOWED_SIZES_SELECTOR); + + $checkboxes.each(function(index, field) { + var api = $(field).adaptTo("foundation-validation"); + if (api) { + api.checkValidity(); + api.updateUI(); + } + }); }); $document.on("foundation-contentloaded", function(e) { @@ -182,35 +206,32 @@ selector: ALLOWED_SIZES_SELECTOR, validate: function(el) { - var $checkboxes = $(el).parent().children(ALLOWED_SIZES_SELECTOR); - var firstEl = $checkboxes.get(0); - var isValid = $(firstEl).data(DATA_ATTR_VALIDATION_STATE); - var validationDone = isValid !== undefined; - - // if the validation has already been done, we get the status from the first checkbox - if (validationDone) { - $(firstEl).removeData(DATA_ATTR_VALIDATION_STATE); - if (!isValid) { - return Granite.I18n.get("Select at least one size option."); - } else { - return; - } + // all Allowed Types / Sizes checkboxes in the same group + var $group = $(el).closest(".core-title-sizes-allowed"); + if ($group.length === 0) { + return; } - // set the validation status on the first checkbox - isValid = false; - $checkboxes.each(function(i, checkbox) { - if (checkbox.checked) { - isValid = true; - return false; + var $inputs = $group.find('input[type="checkbox"][name="./allowedTypes"]'); + if ($inputs.length === 0) { + return; + } + + // check if at least one checkbox is selected + var anyChecked = false; + $inputs.each(function(index, inputEl) { + if ($(inputEl).prop("checked") === true) { + anyChecked = true; + return false; // break } }); - $(firstEl).data(DATA_ATTR_VALIDATION_STATE, isValid); - // trigger the validation on the first checkbox - var api = $(firstEl).adaptTo("foundation-validation"); - api.checkValidity(); - api.updateUI(); + // if all are unchecked, return error message + if (!anyChecked) { + return Granite.I18n.get("Select at least one size option."); + } + + // no return = valid }, show: function(el, message) { var $el = $(el); From d2f1a535d55cbe6e63844bd3fb4c338fa0e3a077 Mon Sep 17 00:00:00 2001 From: pid18718 Date: Wed, 19 Nov 2025 17:11:07 +0100 Subject: [PATCH 2/5] =?UTF-8?q?SITES-35060=20Title=20Component=20Policy=20?= =?UTF-8?q?Dialog=20Throws=20False=20=E2=80=9CSelect=20at=20least=20one=20?= =?UTF-8?q?size=20option=E2=80=9D=20Error=20(SDK=202025.4+)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v2/title/clientlibs/editor/js/title.js | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/content/src/content/jcr_root/apps/core/wcm/components/title/v2/title/clientlibs/editor/js/title.js b/content/src/content/jcr_root/apps/core/wcm/components/title/v2/title/clientlibs/editor/js/title.js index 5bf4567369..f10cf11b4a 100644 --- a/content/src/content/jcr_root/apps/core/wcm/components/title/v2/title/clientlibs/editor/js/title.js +++ b/content/src/content/jcr_root/apps/core/wcm/components/title/v2/title/clientlibs/editor/js/title.js @@ -144,10 +144,10 @@ // Update the default size select when an allowed size is checked/unchecked $document.on("change", ALLOWED_SIZES_SELECTOR, function(e) { - // update default size dropdown as before + // Update the default-size dropdown (existing behavior) updateDefaultSizeSelect(true); - // re-validate all Allowed Types / Sizes checkboxes in this group + // Re-validate all Allowed Types / Sizes checkboxes in the same group var $checkboxes = $(this) .closest(".core-title-sizes-allowed") .find(ALLOWED_SIZES_SELECTOR); @@ -159,6 +159,16 @@ api.updateUI(); } }); + + // Trigger form-level validation so the dialog can enable/disable the Done button + var $form = $(this).closest("form.foundation-form"); + if ($form.length) { + var formApi = $form.adaptTo("foundation-validation"); + if (formApi) { + formApi.checkValidity(); + formApi.updateUI(); + } + } }); $document.on("foundation-contentloaded", function(e) { @@ -201,6 +211,23 @@ toggleDisableAttributeOnLinkLabelAndTitleInputs(); }); + function toggleDialogDoneState(sourceEl, disable) { + // find the closest dialog around the field + var $dialog = $(sourceEl).closest(".cq-dialog, coral-dialog, [role='dialog']"); + if (!$dialog.length) { + return; + } + + // find the Done/submit button inside the dialog + var $doneButtons = $dialog.find(".cq-dialog-submit, [type='submit']"); + if (!$doneButtons.length) { + return; + } + + // enable/disable the button + $doneButtons.prop("disabled", disable); + } + // Display an error if all checkboxes are empty $(window).adaptTo("foundation-registry").register("foundation.validation.validator", { selector: ALLOWED_SIZES_SELECTOR, @@ -226,11 +253,15 @@ } }); - // if all are unchecked, return error message + // if all are unchecked, return error message and disable Done button if (!anyChecked) { + toggleDialogDoneState(el, true); return Granite.I18n.get("Select at least one size option."); } + // at least one is checked: make sure Done button is enabled again + toggleDialogDoneState(el, false); + // no return = valid }, show: function(el, message) { From 32720be4787741120faeb2c4cadaf304dba5b126 Mon Sep 17 00:00:00 2001 From: pid18718 Date: Mon, 24 Nov 2025 10:10:42 +0100 Subject: [PATCH 3/5] =?UTF-8?q?SITES-35060=20Title=20Component=20Policy=20?= =?UTF-8?q?Dialog=20Throws=20False=20=E2=80=9CSelect=20at=20least=20one=20?= =?UTF-8?q?size=20option=E2=80=9D=20Error=20(SDK=202025.4+)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wcm/components/title/v2/title/clientlibs/editor/js/title.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/src/content/jcr_root/apps/core/wcm/components/title/v2/title/clientlibs/editor/js/title.js b/content/src/content/jcr_root/apps/core/wcm/components/title/v2/title/clientlibs/editor/js/title.js index f10cf11b4a..dd8eead792 100644 --- a/content/src/content/jcr_root/apps/core/wcm/components/title/v2/title/clientlibs/editor/js/title.js +++ b/content/src/content/jcr_root/apps/core/wcm/components/title/v2/title/clientlibs/editor/js/title.js @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2017 Adobe Systems Incorporated + * Copyright 2017 Adobe * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From a9e944a55fd5da0d4aee53f73d36e51ed567b2b2 Mon Sep 17 00:00:00 2001 From: pid18718 Date: Thu, 4 Dec 2025 11:09:28 +0100 Subject: [PATCH 4/5] =?UTF-8?q?SITES-35060=20[SLA3]=20Regression=20?= =?UTF-8?q?=E2=80=93=20Title=20Component=20Policy=20Dialog=20Throws=20Fals?= =?UTF-8?q?e=20=E2=80=9CSelect=20at=20least=20one=20size=20option=E2=80=9D?= =?UTF-8?q?=20Error=20(SDK=202025.4+)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v2/title/clientlibs/editor/js/title.js | 26 ------------------- testing/it/it.ui.apps/package-lock.json | 4 +-- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/content/src/content/jcr_root/apps/core/wcm/components/title/v2/title/clientlibs/editor/js/title.js b/content/src/content/jcr_root/apps/core/wcm/components/title/v2/title/clientlibs/editor/js/title.js index dd8eead792..4d67cf35cc 100644 --- a/content/src/content/jcr_root/apps/core/wcm/components/title/v2/title/clientlibs/editor/js/title.js +++ b/content/src/content/jcr_root/apps/core/wcm/components/title/v2/title/clientlibs/editor/js/title.js @@ -30,7 +30,6 @@ var DEFAULT_SIZE_SELECTOR = "coral-select.core-title-size-default"; var DEFAULT_SIZES_SELECTOR = "coral-select.core-title-sizes-default"; var ALLOWED_SIZES_SELECTOR = ".core-title-sizes-allowed coral-checkbox"; - var DATA_ATTR_VALIDATION_STATE = "checkboxes.validation.state"; var SIZES_SELECTOR = "coral-select.core-title-sizes"; var LINK_URL_SELECTOR = ".cmp-title-link-url"; var LINK_LABEL_SELECTOR = ".cmp-title-link-label"; @@ -92,31 +91,6 @@ }); } - // get the appropriate checked box value by checking if the current value of the default type is a valid option in the list of allowed types/sizes - function getAppropriateCheckedBoxValue(checkboxes, currentDefaultTypeValue) { - var isCurrentDefaultTypeValueValidOption = false; - checkboxes.each(function(i, checkbox) { - if (checkbox.checked && checkbox.value === currentDefaultTypeValue) { - isCurrentDefaultTypeValueValidOption = true; - return false; - } - }); - // if the current value of the default type is a valid option, it will return it - if (isCurrentDefaultTypeValueValidOption) { - return currentDefaultTypeValue; - } else { - // if the current value of the default type is a not valid option, it will return the value of the first checked box - var firstCheckedValue = ""; - checkboxes.each(function(i, checkbox) { - if (checkbox.checked) { - firstCheckedValue = checkbox.value; - return false; - } - }); - return firstCheckedValue; - } - } - // toggles the disable attribute of the Link Label and Link Title Attribute inputs, based on the Link Url existence function toggleDisableAttributeOnLinkLabelAndTitleInputs() { $(LINK_LABEL_SELECTOR).prop("disabled", !$(LINK_URL_SELECTOR).val()); diff --git a/testing/it/it.ui.apps/package-lock.json b/testing/it/it.ui.apps/package-lock.json index 89b8d8b271..a1cc31a9f5 100644 --- a/testing/it/it.ui.apps/package-lock.json +++ b/testing/it/it.ui.apps/package-lock.json @@ -1,11 +1,11 @@ { - "name": "com.adobe.cq.core.wcm.components.it.content", + "name": "com.adobe.cq.core.wcm.components.it.ui.apps", "version": "2.30.3-SNAPSHOT", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "com.adobe.cq.core.wcm.components.it.content", + "name": "com.adobe.cq.core.wcm.components.it.ui.apps", "version": "2.30.3-SNAPSHOT", "license": "Apache-2.0", "devDependencies": { From 75d2e4e286a7629f26a4311ef7697c0535428730 Mon Sep 17 00:00:00 2001 From: pid18718 Date: Thu, 4 Dec 2025 13:32:05 +0100 Subject: [PATCH 5/5] =?UTF-8?q?SITES-35060=20[SLA3]=20Regression=20?= =?UTF-8?q?=E2=80=93=20Title=20Component=20Policy=20Dialog=20Throws=20Fals?= =?UTF-8?q?e=20=E2=80=9CSelect=20at=20least=20one=20size=20option=E2=80=9D?= =?UTF-8?q?=20Error.=20Extra=20changes=20revert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- testing/it/it.ui.apps/package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testing/it/it.ui.apps/package-lock.json b/testing/it/it.ui.apps/package-lock.json index a1cc31a9f5..89b8d8b271 100644 --- a/testing/it/it.ui.apps/package-lock.json +++ b/testing/it/it.ui.apps/package-lock.json @@ -1,11 +1,11 @@ { - "name": "com.adobe.cq.core.wcm.components.it.ui.apps", + "name": "com.adobe.cq.core.wcm.components.it.content", "version": "2.30.3-SNAPSHOT", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "com.adobe.cq.core.wcm.components.it.ui.apps", + "name": "com.adobe.cq.core.wcm.components.it.content", "version": "2.30.3-SNAPSHOT", "license": "Apache-2.0", "devDependencies": {