Fix taxonomy checkfield behavior

This commit is contained in:
Gilles Van Assche 2025-09-26 11:19:05 +02:00
parent 67611f7838
commit eb4830a478

View File

@ -145,13 +145,22 @@ function handleHierarchicalTaxonomyCheckboxRelation(e) {
if (e.target.checked && e.target.classList.contains('parent-checkbox')) {
const parentRootTag = e.target.closest('.checkbox-choice');
const children = parentRootTag.querySelectorAll('.child-checkbox');
children.forEach((child) => {
//alert('check parent là');
/*children.forEach((child) => {
child.checked = true;
});
});*/
}
if (e.target.checked && e.target.classList.contains('child-checkbox')) {
//alert('check child là');
const checkboxRootTag = e.target.closest('.checkbox-choice');
const parentCheckbox = checkboxRootTag.parentElement.parentElement.querySelector('.parent-checkbox');
parentCheckbox.checked = false;
}
if (!e.target.checked && e.target.classList.contains('parent-checkbox')) {
// alert('uncheck parent');
//alert('uncheck parent');
const parent = e.target.closest('.checkbox-choice');
const children = parent.querySelectorAll('.child-checkbox');