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

Fixes EuiComboBox Label not calculated correctly #3501

Merged
merged 5 commits into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
@@ -1,5 +1,6 @@
## [`master`](https://github.com/elastic/eui/tree/master)

- Passed `getSelectedOptionForSearchValue` to `EuiComboBoxOptionsList` as prop ([#3501](https://github.com/elastic/eui/pull/3501))
- Added `appendIconComponentCache` function to allow manual pre-emptive loading of source elements into the `EuiIcon` cache ([#3481](https://github.com/elastic/eui/pull/3481))
- Added `initialSelected` to `EuiTableSelectionType` properties to set initial selected checkboxes for `EuiBasicTable` ([#3418](https://github.com/elastic/eui/pull/3418))
- Added exports for `EuiSteps` and related components types ([#3471](https://github.com/elastic/eui/pull/3471))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ exports[`props singleSelection prepend and append is rendered 1`] = `
areAllOptionsSelected={false}
data-test-subj=""
fullWidth={false}
getSelectedOptionForSearchValue={[Function]}
listRef={[Function]}
matchingOptions={
Array [
Expand Down Expand Up @@ -584,6 +585,7 @@ exports[`props singleSelection selects existing option when opened 1`] = `
areAllOptionsSelected={false}
data-test-subj=""
fullWidth={false}
getSelectedOptionForSearchValue={[Function]}
listRef={[Function]}
matchingOptions={
Array [
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 @@ -993,6 +993,7 @@ export class EuiComboBox<T> extends Component<
updatePosition={this.updatePosition}
width={width}
delimiter={delimiter}
getSelectedOptionForSearchValue={getSelectedOptionForSearchValue}
/>
</EuiPortal>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export type EuiComboBoxOptionsListProps<T> = CommonProps &
getSelectedOptionForSearchValue?: (
searchValue: string,
selectedOptions: any[]
) => EuiComboBoxOptionOption<T>;
) => EuiComboBoxOptionOption<T> | undefined;
Comment on lines 67 to +70
Copy link
Contributor

Choose a reason for hiding this comment

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

why using undefined here when ? at the end of getSelectedOptionForSearchValue already suggests that undefined is acceptable

Copy link
Contributor Author

@ashikmeerankutty ashikmeerankutty May 19, 2020

Choose a reason for hiding this comment

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

If undefined is not given. It creates a lint error. I guess, In this case, the props value is undefined not the prop.

Copy link
Contributor

Choose a reason for hiding this comment

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

In this case, the props value is undefined not the prop

Correct. The ? allows for getSelectedOptionForSearchValue itself to be undefined.
(getSelectedOptionForSearchValue={undefined})
But adding | undefined allows for the value returned by the getSelectedOptionForSearchValue function to be undefined
(getSelectedOptionForSearchValue={(booleanParam) => booleanParam ? 'hello' : undefined})

isLoading?: boolean;
listRef: RefCallback<HTMLDivElement>;
matchingOptions: Array<EuiComboBoxOptionOption<T>>;
Expand Down