Skip to content

Commit

Permalink
[EuiComboBox] Fix issue with duplicate checkmarks (#4162)
Browse files Browse the repository at this point in the history
* [EuiComboBox] Fix issue with duplicate checkmarks

* Remove accidentally commited test code

* Add changelog entry

* Fix changelog entry
  • Loading branch information
Tim Roes authored Oct 20, 2020
1 parent ca5489c commit 1eff48a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## [`master`](https://github.com/elastic/eui/tree/master)

No public interface changes since `30.0.0`.
**Bug fixes**

- Fix issue with duplicate checkmarks in `EuiComboBox` ([4162](https://github.com/elastic/eui/pull/4162))


## [`30.0.0`](https://github.com/elastic/eui/tree/v30.0.0)

Expand Down
28 changes: 28 additions & 0 deletions src/components/combo_box/combo_box.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,34 @@ describe('props', () => {
});
});

test('does not show multiple checkmarks with duplicate labels', () => {
const options = [
{
label: 'Titan',
key: 'titan1',
},
{
label: 'Titan',
key: 'titan2',
},
{
label: 'Tethys',
},
];
const component = mount(
<EuiComboBox
singleSelection={{ asPlainText: true }}
options={options}
selectedOptions={[options[1]]}
/>
);

const searchInput = findTestSubject(component, 'comboBoxSearchInput');
searchInput.simulate('focus');

expect(component.find('EuiFilterSelectItem[checked="on"]').length).toBe(1);
});

describe('behavior', () => {
describe('hitting "Enter"', () => {
test('calls the onCreateOption callback when there is input', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ export class EuiComboBoxOptionsList<T> extends Component<
if (
singleSelection &&
selectedOptions.length &&
selectedOptions[0].label === label
selectedOptions[0].label === label &&
selectedOptions[0].key === key
) {
checked = 'on';
}
Expand Down

0 comments on commit 1eff48a

Please sign in to comment.