Skip to content

Commit

Permalink
removed dependency on option list of custom option (elastic#3183)
Browse files Browse the repository at this point in the history
* removed dependedncy on option list of custom option

* reverted all changes

* CL

* Optimized
  • Loading branch information
anishagg17 authored and Marvin9 committed Apr 2, 2020
1 parent e9a673b commit e34cdd6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## [`master`](https://github.com/elastic/eui/tree/master)

- Removed dependency on option list for custom option of `EuiComboBox` ([#3183](https://github.com/elastic/eui/pull/3183))
- Fixed `EuiPopover` arrow position in Android and Linux ([#3188](https://github.com/elastic/eui/pull/3188))
- Improved `htmlIdGenerator` when supplying both `prefix` and `suffix` ([#3076](https://github.com/elastic/eui/pull/3076))
- Updated pagination prop descriptions for `EuiInMemoryTable` ([#3142](https://github.com/elastic/eui/pull/3142))
Expand Down
16 changes: 15 additions & 1 deletion src/components/combo_box/combo_box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,21 @@ export class EuiComboBox<T> extends Component<
if (async) {
return false;
}
return flattenOptionGroups(options).length === selectedOptions.length;

const flattenOptions = flattenOptionGroups(options).map(option => {
return { ...option, label: option.label.trim().toLowerCase() };
});

let numberOfSelectedOptions = 0;
selectedOptions.forEach(({ label }) => {
const trimmedLabel = label.trim().toLowerCase();
if (
flattenOptions.findIndex(option => option.label === trimmedLabel) !== -1
)
numberOfSelectedOptions += 1;
});

return flattenOptions.length === numberOfSelectedOptions;
};

isSingleSelectionCustomOption = () => {
Expand Down

0 comments on commit e34cdd6

Please sign in to comment.