@energycap/components 0.39.17-ECAP-23124-menu-item-divider-improvements.20240523-1609 → 0.39.17-ECAP-23124-menu-item-divider-improvements.20240528-1347
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 +6 -1
- package/fesm2015/energycap-components.mjs +12 -1
- package/fesm2015/energycap-components.mjs.map +1 -1
- package/fesm2020/energycap-components.mjs +12 -1
- package/fesm2020/energycap-components.mjs.map +1 -1
- package/package.json +1 -1
@@ -2244,6 +2244,11 @@ class MenuComponent {
|
|
2244
2244
|
if (this.items) {
|
2245
2245
|
this.items.forEach((item, index) => {
|
2246
2246
|
item.id = item.id ? item.id : this.id + '_item' + index;
|
2247
|
+
if (item.items) {
|
2248
|
+
item.items.forEach((childItem, childIndex) => {
|
2249
|
+
childItem.id = childItem.id ? childItem.id : this.id + '_item' + index + '-' + childIndex;
|
2250
|
+
});
|
2251
|
+
}
|
2247
2252
|
});
|
2248
2253
|
}
|
2249
2254
|
}
|
@@ -3207,11 +3212,17 @@ class ComboboxComponent extends FormControlBase {
|
|
3207
3212
|
if (filterText && filterText !== '') {
|
3208
3213
|
const matchesSearch = (item) => item.label.toLowerCase().indexOf(searchText) >= 0 || (item.caption && item.caption.toLowerCase().indexOf(searchText) >= 0);
|
3209
3214
|
return this.options.reduce((filteredItems, item) => {
|
3215
|
+
// Match the item itself if it doesn't have any children
|
3210
3216
|
if (!item.items?.length && matchesSearch(item)) {
|
3211
3217
|
filteredItems.push(item);
|
3218
|
+
// If we have children, filter them and add the parent if it has any children that match
|
3212
3219
|
}
|
3213
3220
|
else if (item.items?.length && (item.display === 'heading' || item.display === 'divided-section')) {
|
3214
|
-
|
3221
|
+
const filteredChildItems = item.items.filter(matchesSearch);
|
3222
|
+
if (filteredChildItems.length) {
|
3223
|
+
// Need to clone the parent item with the filtered children so we don't modify the original
|
3224
|
+
filteredItems.push({ ...item, items: filteredChildItems });
|
3225
|
+
}
|
3215
3226
|
}
|
3216
3227
|
return filteredItems;
|
3217
3228
|
}, []);
|