Closed sleepybjr closed 2 years ago
If you use an optionGroupChildren parameter that isn't "item", then filtering will not work properly on grouped options for multiselect.
The issue is below. "items" is hardcoded so it will not replace the custom named children list with the filtered options, and you will always receive all the options of the group when filtering. https://github.com/primefaces/primereact/blob/7cb4bc1327ce4ff71cc1943c205fa5a2f8613020/components/lib/multiselect/MultiSelect.js#L489
It should be: filteredGroups.push({ ...optgroup, ...{ [props.optionGroupChildren] : filteredSubOptions } });
filteredGroups.push({ ...optgroup, ...{ [props.optionGroupChildren] : filteredSubOptions } });
https://codesandbox.io/s/primereact-test-forked-0g9typ
8.0.1
18.x
ALL
Next.js
No response
Only the filtered option should show, not the group of the filtered option.
I completely agree with your fix! Much appreciated for the report and the diagnosis!
Describe the bug
If you use an optionGroupChildren parameter that isn't "item", then filtering will not work properly on grouped options for multiselect.
The issue is below. "items" is hardcoded so it will not replace the custom named children list with the filtered options, and you will always receive all the options of the group when filtering. https://github.com/primefaces/primereact/blob/7cb4bc1327ce4ff71cc1943c205fa5a2f8613020/components/lib/multiselect/MultiSelect.js#L489
It should be:
filteredGroups.push({ ...optgroup, ...{ [props.optionGroupChildren] : filteredSubOptions } });
Reproducer
https://codesandbox.io/s/primereact-test-forked-0g9typ
PrimeReact version
8.0.1
React version
18.x
Language
ALL
Build / Runtime
Next.js
Browser(s)
No response
Steps to reproduce the behavior
Expected behavior
Only the filtered option should show, not the group of the filtered option.