diff --git a/CHANGELOG.md b/CHANGELOG.md index b6733031b3fe..a1b58c3a36ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/src/components/combo_box/combo_box.tsx b/src/components/combo_box/combo_box.tsx index ebad2f90cd52..b3f6b7940686 100644 --- a/src/components/combo_box/combo_box.tsx +++ b/src/components/combo_box/combo_box.tsx @@ -472,7 +472,21 @@ export class EuiComboBox 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 = () => {