From ad6b71074a630c797b29253864e418b9c85aee5a Mon Sep 17 00:00:00 2001 From: Inesh Bose <56732164+ineshbose@users.noreply.github.com> Date: Mon, 27 Mar 2023 11:32:57 +0100 Subject: [PATCH] fix: visibleOptions respecting optionGroupChildren (#3804) --- components/lib/dropdown/Dropdown.vue | 5 +++-- components/lib/multiselect/MultiSelect.vue | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/components/lib/dropdown/Dropdown.vue b/components/lib/dropdown/Dropdown.vue index 512493d41..edf781ae7 100755 --- a/components/lib/dropdown/Dropdown.vue +++ b/components/lib/dropdown/Dropdown.vue @@ -978,9 +978,10 @@ export default { const filtered = []; optionGroups.forEach((group) => { - const filteredItems = group.items.filter((item) => filteredOptions.includes(item)); + const groupChildren = this.getOptionGroupChildren(group); + const filteredItems = groupChildren.filter((item) => filteredOptions.includes(item)); - if (filteredItems.length > 0) filtered.push({ ...group, items: [...filteredItems] }); + if (filteredItems.length > 0) filtered.push({ ...group, [typeof this.optionGroupChildren === 'string' ? this.optionGroupChildren : 'items']: [...filteredItems] }); }); return this.flatOptions(filtered); diff --git a/components/lib/multiselect/MultiSelect.vue b/components/lib/multiselect/MultiSelect.vue index 9334d8463..eda574102 100755 --- a/components/lib/multiselect/MultiSelect.vue +++ b/components/lib/multiselect/MultiSelect.vue @@ -1093,9 +1093,10 @@ export default { const filtered = []; optionGroups.forEach((group) => { - const filteredItems = group.items.filter((item) => filteredOptions.includes(item)); + const groupChildren = this.getOptionGroupChildren(group); + const filteredItems = groupChildren.filter((item) => filteredOptions.includes(item)); - if (filteredItems.length > 0) filtered.push({ ...group, items: [...filteredItems] }); + if (filteredItems.length > 0) filtered.push({ ...group, [typeof this.optionGroupChildren === 'string' ? this.optionGroupChildren : 'items']: [...filteredItems] }); }); return this.flatOptions(filtered);