Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check mark to singleSelection EuiComboBox #2890

Merged
merged 8 commits into from
Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -11,6 +11,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 @@ -517,6 +517,7 @@ exports[`props singleSelection selects existing option when opened 1`] = `
},
]
}
singleSelection={true}
updatePosition={[Function]}
/>
</EuiPortal>
Expand Down
1 change: 1 addition & 0 deletions src/components/combo_box/combo_box.js
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ export class EuiComboBox extends Component {
getSelectedOptionForSearchValue={getSelectedOptionForSearchValue}
updatePosition={this.updateListPosition}
position={listPosition}
singleSelection={singleSelection}
renderOption={renderOption}
width={width}
scrollToIndex={activeOptionIndex}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
0 -2px 4px -1px transparentize($euiShadowColor, .8),
0 0 2px 0 transparentize($euiShadowColor, .8);
}

.euiFilterSelectItem__crossIcon {
visibility: hidden; // hiding cross icon in single selection combo box
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@andreadelrio I'm confused by this one. Can you explain why the cross would show up in singleSelection combo boxes and why it'd be necessary to force hide it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops, I was overcomplicating things, passing null to checked was enough. I made the changes.

}

.euiComboBoxOptionsList--bottom {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export class EuiComboBoxOptionsList extends Component {
listRef,
updatePosition,
width,
singleSelection,
scrollToIndex,
onScroll,
rowHeight,
Expand Down Expand Up @@ -271,9 +272,10 @@ export class EuiComboBoxOptionsList extends Component {
// onEnterKey={onOptionEnterKey}
ref={optionRef.bind(this, index)}
isFocused={activeOptionIndex === index}
checked={activeOptionIndex === index ? 'on' : 'off'}
id={rootId(`_option-${index}`)}
title={label}
showIcons={false}
showIcons={singleSelection}
{...rest}>
{renderOption ? (
renderOption(option, searchValue, OPTION_CONTENT_CLASSNAME)
Expand Down
16 changes: 12 additions & 4 deletions src/components/filter_group/filter_select_item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@ const resolveIconAndColor = (checked?: FilterChecked) => {
return { icon: 'empty' };
}
return checked === 'on'
? { icon: 'check', color: 'text' }
: { icon: 'cross', color: 'text' };
? {
icon: 'check',
color: 'text',
className: 'euiFilterSelectItem__checkIcon',
}
: {
icon: 'cross',
color: 'text',
className: 'euiFilterSelectItem__crossIcon',
};
};

export class EuiFilterSelectItem extends Component<EuiFilterSelectItemProps> {
Expand Down Expand Up @@ -66,10 +74,10 @@ export class EuiFilterSelectItem extends Component<EuiFilterSelectItemProps> {

let iconNode;
if (showIcons) {
const { icon, color } = resolveIconAndColor(checked);
const { icon, color, className } = resolveIconAndColor(checked);
iconNode = (
<EuiFlexItem grow={false}>
<EuiIcon color={color} type={icon} />
<EuiIcon className={className} color={color} type={icon} />
</EuiFlexItem>
);
}
Expand Down