Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Added `image` glyph to `EuiIcon` ([#2870](https://github.com/elastic/eui/pull/2870))
- Exported TS props from top level `EuiListGroupProps`, `EuiListGroupItemProps`, `EuiSelectableProps`, `EuiSelectableOption`, `EuiSelectableOptionsListProps` ([#2869](https://github.com/elastic/eui/pull/2869))
- Extending `EuiSelectable[options]` type with correct HTML element ([#2869](https://github.com/elastic/eui/pull/2869))
- Added check mark to single selection `EuiComboBox` ([#2890](https://github.com/elastic/eui/pull/2890))

**Bug fixes**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ exports[`props singleSelection selects existing option when opened 1`] = `
},
]
}
singleSelection={true}
updatePosition={[Function]}
width={0}
/>
Expand Down
1 change: 1 addition & 0 deletions src/components/combo_box/combo_box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,7 @@ export class EuiComboBox<T> extends Component<
optionRef={this.optionRefCallback}
options={options}
position={listPosition}
singleSelection={singleSelection}
renderOption={renderOption}
rootId={this.rootId}
rowHeight={rowHeight}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { htmlIdGenerator } from '../../../services';
import {
EuiComboBoxOptionOption,
EuiComboBoxOptionsListPosition,
EuiComboBoxSingleSelectionShape,
OptionHandler,
RefCallback,
RefInstance,
Expand Down Expand Up @@ -67,6 +68,7 @@ export type EuiComboBoxOptionsListProps<T> = CommonProps &
selectedOptions: Array<EuiComboBoxOptionOption<T>>;
updatePosition: UpdatePositionHandler;
width: number;
singleSelection?: boolean | EuiComboBoxSingleSelectionShape;
};

export class EuiComboBoxOptionsList<T> extends Component<
Expand Down Expand Up @@ -167,6 +169,7 @@ export class EuiComboBoxOptionsList<T> extends Component<
scrollToIndex,
searchValue,
selectedOptions,
singleSelection,
updatePosition,
width,
...rest
Expand Down Expand Up @@ -271,12 +274,7 @@ export class EuiComboBoxOptionsList<T> extends Component<
onScroll={onScroll}
rowRenderer={({ key, index, style }) => {
const option = matchingOptions[index];
const {
isGroupLabelOption,
label,
value, // eslint-disable-line no-unused-vars
...rest
} = option;
const { isGroupLabelOption, label, value, ...rest } = option;

if (isGroupLabelOption) {
return (
Expand All @@ -286,6 +284,15 @@ export class EuiComboBoxOptionsList<T> extends Component<
);
}

let checked: 'on' | 'off' = 'off';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thompsongl I don't think this is correct. off would mean the icon shows a cross instead of no icon. It should be undefined or on.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen Shot 2020-02-24 at 11 32 54 AM

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok. Good catch

if (
singleSelection &&
selectedOptions.length &&
selectedOptions[0].label === label
) {
checked = 'on';
}

return (
<EuiFilterSelectItem
style={style}
Expand All @@ -297,9 +304,10 @@ export class EuiComboBoxOptionsList<T> extends Component<
}}
ref={optionRef.bind(this, index)}
isFocused={activeOptionIndex === index}
checked={checked}
showIcons={singleSelection ? true : false}
id={rootId(`_option-${index}`)}
title={label}
showIcons={false}
{...rest}>
{renderOption ? (
renderOption(option, searchValue, OPTION_CONTENT_CLASSNAME)
Expand Down
10 changes: 8 additions & 2 deletions src/components/filter_group/filter_select_item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@ const resolveIconAndColor = (checked?: FilterChecked) => {
return { icon: 'empty' };
}
return checked === 'on'
? { icon: 'check', color: 'text' }
: { icon: 'cross', color: 'text' };
? {
icon: 'check',
color: 'text',
}
: {
icon: 'cross',
color: 'text',
};
};

export class EuiFilterSelectItem extends Component<EuiFilterSelectItemProps> {
Expand Down