diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d211b3c6f8..dcfc7e59ea5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## [`master`](https://github.com/elastic/eui/tree/master) -No public interface changes since `22.1.0`. +**Bug Fixes** + +- Fixed EuiBasicTable proptypes of itemId ([#3133](https://github.com/elastic/eui/pull/3133)) ## [`22.1.0`](https://github.com/elastic/eui/tree/v22.1.0) diff --git a/src-docs/src/views/tables/basic/props_info.js b/src-docs/src/views/tables/basic/props_info.js index 6f88d07d9eb..a7315397d9b 100644 --- a/src-docs/src/views/tables/basic/props_info.js +++ b/src-docs/src/views/tables/basic/props_info.js @@ -12,7 +12,7 @@ export const propsInfo = { description: 'Describes how to extract a unique ID from each item, used for selections & expanded rows', required: false, - type: { name: 'string | (item) => string' }, + type: { name: 'string | number | (item) => string' }, }, itemIdToExpandedRowMap: { description: diff --git a/src/components/basic_table/basic_table.tsx b/src/components/basic_table/basic_table.tsx index a7c63d33fab..71d8ee7e7ac 100644 --- a/src/components/basic_table/basic_table.tsx +++ b/src/components/basic_table/basic_table.tsx @@ -53,6 +53,7 @@ import { ItemId, EuiTableSelectionType, EuiTableSortingType, + ItemIdResolved, } from './table_types'; import { EuiTableSortMobileProps } from '../table/mobile/table_sort_mobile'; @@ -863,7 +864,7 @@ export class EuiBasicTable extends Component< const cells = []; const { itemId: itemIdCallback } = this.props; - const itemId = getItemId(item, itemIdCallback) || rowIndex; + const itemId: ItemIdResolved = getItemId(item, itemIdCallback) || rowIndex; const selected = !selection ? false : this.state.selection && @@ -1021,7 +1022,7 @@ export class EuiBasicTable extends Component< } renderItemActionsCell( - itemId: ItemId, + itemId: ItemIdResolved, item: T, column: EuiTableActionsColumnType, columnIndex: number diff --git a/src/components/basic_table/collapsed_item_actions.tsx b/src/components/basic_table/collapsed_item_actions.tsx index 7586465172c..70142c69070 100644 --- a/src/components/basic_table/collapsed_item_actions.tsx +++ b/src/components/basic_table/collapsed_item_actions.tsx @@ -10,12 +10,12 @@ import { DefaultItemIconButtonAction, } from './action_types'; import { EuiIconType } from '../icon/icon'; -import { ItemId } from './table_types'; +import { ItemIdResolved } from './table_types'; export interface CollapsedItemActionsProps { actions: Array>; item: T; - itemId: ItemId; + itemId: ItemIdResolved; actionEnabled: (action: Action) => boolean; className?: string; onFocus?: (event: FocusEvent) => void; diff --git a/src/components/basic_table/expanded_item_actions.tsx b/src/components/basic_table/expanded_item_actions.tsx index d15b1b73698..a19be31f821 100644 --- a/src/components/basic_table/expanded_item_actions.tsx +++ b/src/components/basic_table/expanded_item_actions.tsx @@ -7,11 +7,11 @@ import { CustomItemAction as CustomAction, DefaultItemAction as DefaultAction, } from './action_types'; -import { ItemId } from './table_types'; +import { ItemIdResolved } from './table_types'; export interface ExpandedItemActionsProps { actions: Array>; - itemId: ItemId; + itemId: ItemIdResolved; item: T; actionEnabled: (action: Action) => boolean; className?: string; diff --git a/src/components/basic_table/table_types.ts b/src/components/basic_table/table_types.ts index 1a79f8257a5..8cfe8b4f206 100644 --- a/src/components/basic_table/table_types.ts +++ b/src/components/basic_table/table_types.ts @@ -5,7 +5,9 @@ import { Action } from './action_types'; import { Primitive } from '../../services/sort/comparators'; import { CommonProps } from '../common'; -export type ItemId = string | ((item: T) => string); +export type ItemId = string | number | ((item: T) => string); +export type ItemIdResolved = string | number; + export type EuiTableDataType = | 'auto' | 'string'