Skip to content
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

- Updated `barSeriesStyle.displayValue` of the elastic-charts `Theme` for better default styles ([#4845](https://github.com/elastic/eui/pull/4845))
- Updated `titleProps` and `descriptionProps` on `EuiDescriptionList` to extend `CommonProps` ([#5166](https://github.com/elastic/eui/pull/5166))
- Added the ability to return `visibleOptions` from `EuiSelectable` by using `onSearch` ([#5178](https://github.com/elastic/eui/pull/5178))

**Bug fixes**

- Fixed `EuiDataGrid` focus ring to be contained in the cell ([#5194](https://github.com/elastic/eui/pull/5194))
- Fixed `EuiDataGrid` cells when focused getting a higher `z-index` which was causing long content to overlap surrounding cells ([#5194](https://github.com/elastic/eui/pull/5194))


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

- Added optional line numbers to `EuiCodeBlock` ([#4993](https://github.com/elastic/eui/pull/4993))
Expand Down
5 changes: 5 additions & 0 deletions src-docs/src/views/selectable/props.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { FunctionComponent } from 'react';
import {
EuiSelectableOption,
EuiSelectableOptionsListProps,
EuiSelectableSearchableSearchProps,
} from '../../../../src/components/selectable';

import {
Expand All @@ -17,6 +18,10 @@ export const EuiSelectableOptionsList: FunctionComponent<EuiSelectableOptionsLis
<div />
);

export const EuiSelectableSearchProps: FunctionComponent<EuiSelectableSearchableSearchProps<
any
>> = () => <div />;

export const Options: FunctionComponent<EuiSelectableTemplateSitewideOption> = () => (
<div />
);
Expand Down
6 changes: 5 additions & 1 deletion src-docs/src/views/selectable/selectable_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import {
EuiSelectableOptionProps,
EuiSelectableOptionsList,
EuiSelectableSearchProps,
Options,
MetaData,
} from './props';
Expand Down Expand Up @@ -153,7 +154,9 @@ export const SelectableExample = {
To add a search component to the list, simply add the{' '}
<EuiCode>searchable</EuiCode> prop. You can optionally pass in a{' '}
<EuiCode>searchProps</EuiCode> object which will get passed down to
the actual <strong>EuiFieldSearch</strong> used.
the actual <strong>EuiFieldSearch</strong> used. In this example,
<EuiCode>onSearch</EuiCode> will return a second parameter, enabling
you to access the list of filtered items
</p>
<EuiCallOut
iconType="search"
Expand All @@ -171,6 +174,7 @@ export const SelectableExample = {
EuiSelectable,
EuiSelectableOptionProps,
EuiSelectableOptionsList,
EuiSelectableSearchProps,
},
demo: <SelectableSearch />,
snippet: `<EuiSelectable
Expand Down
6 changes: 5 additions & 1 deletion src/components/selectable/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
* Side Public License, v 1.
*/

export { EuiSelectable, EuiSelectableProps } from './selectable';
export {
EuiSelectable,
EuiSelectableProps,
EuiSelectableSearchableSearchProps,
} from './selectable';
export {
EuiSelectableList,
EuiSelectableListProps,
Expand Down
18 changes: 14 additions & 4 deletions src/components/selectable/selectable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,19 @@ type EuiSelectableSearchableProps<T> = ExclusiveUnion<
*/
searchable: true;
/**
* Passes props down to the `EuiFieldSearch`
* Passes props down to the `EuiFieldSearch`.
* See #EuiSelectableSearchProps
*/
searchProps?: Partial<EuiSelectableSearchProps<T>>;
searchProps?: EuiSelectableSearchableSearchProps<T>;
}
>;

export type EuiSelectableSearchableSearchProps<T> = Partial<
Omit<EuiSelectableSearchProps<T>, 'onSearch'> & {
onSearch: (
searchValue: string,
matchingOptions: Array<EuiSelectableOption<T>>
) => void;
}
>;

Expand Down Expand Up @@ -337,7 +347,7 @@ export class EuiSelectable<T = {}> extends Component<
}
);
if (this.props.searchProps && this.props.searchProps.onSearch) {
this.props.searchProps.onSearch(searchValue);
this.props.searchProps.onSearch(searchValue, visibleOptions);
}
};

Expand Down Expand Up @@ -524,7 +534,7 @@ export class EuiSelectable<T = {}> extends Component<
*/
const getAccessibleName = (
props:
| Partial<EuiSelectableSearchProps<T>>
| EuiSelectableSearchableSearchProps<T>
| EuiSelectableOptionsListPropsWithDefaults
| undefined,
messageContentId?: string
Expand Down