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 1 commit
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
9 changes: 1 addition & 8 deletions src/components/combo_box/combo_box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -812,14 +812,6 @@ export class EuiComboBox<T> extends Component<
<EuiComboBoxOptionsList
activeOptionIndex={this.state.activeOptionIndex}
areAllOptionsSelected={this.areAllOptionsSelected()}
getSelectedOptionForSearchValue={getSelectedOptionForSearchValue}
updatePosition={this.updateListPosition}
position={listPosition}
singleSelection={singleSelection}
renderOption={renderOption}
width={width}
scrollToIndex={activeOptionIndex}
rowHeight={rowHeight}
data-test-subj={optionsListDataTestSubj}
fullWidth={fullWidth}
isLoading={isLoading}
Expand All @@ -833,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 @@ -145,27 +147,6 @@ export class EuiComboBoxOptionsList<T> extends Component<

render() {
const {
options,
isLoading,
selectedOptions,
onCreateOption,
searchValue,
matchingOptions,
optionRef,
onOptionClick,
onOptionEnterKey,
areAllOptionsSelected,
getSelectedOptionForSearchValue,
position,
renderOption,
listRef,
updatePosition,
width,
singleSelection,
scrollToIndex,
onScroll,
rowHeight,
fullWidth,
'data-test-subj': dataTestSubj,
activeOptionIndex,
areAllOptionsSelected,
Expand All @@ -188,6 +169,7 @@ export class EuiComboBoxOptionsList<T> extends Component<
scrollToIndex,
searchValue,
selectedOptions,
singleSelection,
updatePosition,
width,
...rest
Expand Down Expand Up @@ -292,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 @@ -307,12 +284,13 @@ export class EuiComboBoxOptionsList<T> extends Component<
);
}

let checked;
if (singleSelection) {
checked =
selectedOptions.length && selectedOptions[0].label === label
? 'on'
: null;
let checked: 'on' | 'off' = 'off';
Copy link
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
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
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 (
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.