diff --git a/components/lib/dropdown/Dropdown.js b/components/lib/dropdown/Dropdown.js
index 14af03efde..0a4ae10c97 100644
--- a/components/lib/dropdown/Dropdown.js
+++ b/components/lib/dropdown/Dropdown.js
@@ -57,7 +57,21 @@ export const Dropdown = React.memo(
when: overlayVisibleState
});
+ const flatOptions = (options) => {
+ return (options || []).reduce((result, option, index) => {
+ result.push({ optionGroup: option, group: true, index, code: option.code, label: option.label });
+
+ const optionGroupChildren = getOptionGroupChildren(option);
+
+ optionGroupChildren && optionGroupChildren.forEach((o) => result.push(o));
+
+ return result;
+ }, []);
+ };
+
const getVisibleOptions = () => {
+ const options = props.optionGroupLabel ? flatOptions(props.options) : props.options;
+
if (hasFilter && !isLazy) {
const filterValue = filterState.trim().toLocaleLowerCase(props.filterLocale);
const searchFields = props.filterBy ? props.filterBy.split(',') : [props.optionLabel || 'label'];
@@ -73,13 +87,13 @@ export const Dropdown = React.memo(
}
}
- return filteredGroups;
+ return flatOptions(filteredGroups);
}
- return FilterService.filter(props.options, searchFields, filterValue, props.filterMatchMode, props.filterLocale);
+ return FilterService.filter(options, searchFields, filterValue, props.filterMatchMode, props.filterLocale);
}
- return props.options;
+ return options;
};
const onFirstHiddenFocus = (event) => {
diff --git a/components/lib/dropdown/DropdownPanel.js b/components/lib/dropdown/DropdownPanel.js
index fbf9b416a2..2072814fc1 100644
--- a/components/lib/dropdown/DropdownPanel.js
+++ b/components/lib/dropdown/DropdownPanel.js
@@ -76,36 +76,6 @@ export const DropdownPanel = React.memo(
}
};
- const createGroupChildren = (optionGroup, style) => {
- const groupChildren = props.getOptionGroupChildren(optionGroup);
-
- return groupChildren.map((option, j) => {
- const optionLabel = props.getOptionLabel(option);
- const optionKey = j + '_' + props.getOptionRenderKey(option);
- const disabled = props.isOptionDisabled(option);
-
- return (
-