Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions packages/eui/changelogs/upcoming/9253.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**Bug fixes**

- Fixed `EuiSearchBarOnChangeArgs` type to restore proper type narrowing when checking for `error` (regression from #9142), decoupling `searchFormat="text"` behavior in `EuiInMemoryTable` from `EuiSearchBar`

10 changes: 8 additions & 2 deletions packages/eui/src/components/basic_table/in_memory_table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,19 @@ interface onChangeArgument {
error: Error | null;
}

// allows `query: null` in the onChange callback when using `searchFormat="text"`
interface EuiInMemoryTableSearchBarProps
Comment thread
acstll marked this conversation as resolved.
Outdated
extends Omit<EuiSearchBarProps, 'onChange'> {
onChange?: (args: onChangeArgument) => void | boolean;
}

function isEuiSearchBarProps<T extends object>(
x: EuiInMemoryTableProps<T>['search']
): x is EuiSearchBarProps {
): x is EuiInMemoryTableSearchBarProps {
return typeof x !== 'boolean';
}

export type Search = boolean | EuiSearchBarProps;
export type Search = boolean | EuiInMemoryTableSearchBarProps;

interface PaginationOptions extends EuiTablePaginationProps {
pageSizeOptions?: number[];
Expand Down
15 changes: 1 addition & 14 deletions packages/eui/src/components/search_bar/search_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ interface ArgsWithQuery {
error: null;
}

/**
* When `searchFormat` is 'text', `query` is null and the search is performed
* on the `queryText` directly without EQL parsing
*/
interface ArgsWithPlainText {
query: null;
queryText: string;
error: null;
}

interface ArgsWithError {
query: null;
queryText: string;
Expand All @@ -58,10 +48,7 @@ export interface SchemaType {
recognizedFields?: string[];
}

export type EuiSearchBarOnChangeArgs =
| ArgsWithQuery
| ArgsWithPlainText
| ArgsWithError;
export type EuiSearchBarOnChangeArgs = ArgsWithQuery | ArgsWithError;

type HintPopOverProps = Partial<
Pick<
Expand Down