@energycap/components 0.39.17-ECAP-23124-menu-item-divider-improvements.20240523-1134 → 0.39.17-ECAP-23124-menu-item-divider-improvements.20240523-1631
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/controls/combobox/combobox.component.mjs +8 -2
- package/esm2020/lib/controls/menu/menu.component.mjs +2 -2
- package/fesm2015/energycap-components.mjs +8 -2
- package/fesm2015/energycap-components.mjs.map +1 -1
- package/fesm2020/energycap-components.mjs +8 -2
- package/fesm2020/energycap-components.mjs.map +1 -1
- package/package.json +1 -1
@@ -2082,7 +2082,7 @@ class MenuComponent {
|
|
2082
2082
|
* @param item The selected item
|
2083
2083
|
*/
|
2084
2084
|
onSelection(item) {
|
2085
|
-
if (item.display !== 'heading') {
|
2085
|
+
if (item.display !== 'heading' && item.display !== 'divided-section') {
|
2086
2086
|
this.selectedChanged.emit(item);
|
2087
2087
|
}
|
2088
2088
|
}
|
@@ -3207,11 +3207,17 @@ class ComboboxComponent extends FormControlBase {
|
|
3207
3207
|
if (filterText && filterText !== '') {
|
3208
3208
|
const matchesSearch = (item) => item.label.toLowerCase().indexOf(searchText) >= 0 || (item.caption && item.caption.toLowerCase().indexOf(searchText) >= 0);
|
3209
3209
|
return this.options.reduce((filteredItems, item) => {
|
3210
|
+
// Match the item itself if it doesn't have any children
|
3210
3211
|
if (!item.items?.length && matchesSearch(item)) {
|
3211
3212
|
filteredItems.push(item);
|
3213
|
+
// If we have children, filter them and add the parent if it has any children that match
|
3212
3214
|
}
|
3213
3215
|
else if (item.items?.length && (item.display === 'heading' || item.display === 'divided-section')) {
|
3214
|
-
|
3216
|
+
const filteredChildItems = item.items.filter(matchesSearch);
|
3217
|
+
if (filteredChildItems.length) {
|
3218
|
+
// Need to clone the parent item with the filtered children so we don't modify the original
|
3219
|
+
filteredItems.push({ ...item, items: filteredChildItems });
|
3220
|
+
}
|
3215
3221
|
}
|
3216
3222
|
return filteredItems;
|
3217
3223
|
}, []);
|