Skip to content

Commit

Permalink
fix(EuiBasicTable): fixed EuiBasicTable proptypes of itemId (#3133)
Browse files Browse the repository at this point in the history
* fix(EuiBasicTable): fixed EuiBasicTable proptypes of itemId

* fix(types): Fixed ItemId type

* fix(EuiBasicTable): fixed EuiBasicTable proptypes of itemId

chore(CHANGELOG): updated the changelog

docs(EuiBasicTable): updated propTypes

* fix(types): fixed propTypes for the ItemId in multiple components

Co-authored-by: Chandler Prall <chandler.prall@gmail.com>
  • Loading branch information
pranshuchittora and chandlerprall authored Mar 26, 2020
1 parent 74624c2 commit a4eecae
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion src-docs/src/views/tables/basic/props_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions src/components/basic_table/basic_table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
ItemId,
EuiTableSelectionType,
EuiTableSortingType,
ItemIdResolved,
} from './table_types';
import { EuiTableSortMobileProps } from '../table/mobile/table_sort_mobile';

Expand Down Expand Up @@ -863,7 +864,7 @@ export class EuiBasicTable<T = any> 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 &&
Expand Down Expand Up @@ -1021,7 +1022,7 @@ export class EuiBasicTable<T = any> extends Component<
}

renderItemActionsCell(
itemId: ItemId<T>,
itemId: ItemIdResolved,
item: T,
column: EuiTableActionsColumnType<T>,
columnIndex: number
Expand Down
4 changes: 2 additions & 2 deletions src/components/basic_table/collapsed_item_actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {
actions: Array<Action<T>>;
item: T;
itemId: ItemId<T>;
itemId: ItemIdResolved;
actionEnabled: (action: Action<T>) => boolean;
className?: string;
onFocus?: (event: FocusEvent) => void;
Expand Down
4 changes: 2 additions & 2 deletions src/components/basic_table/expanded_item_actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {
actions: Array<Action<T>>;
itemId: ItemId<T>;
itemId: ItemIdResolved;
item: T;
actionEnabled: (action: Action<T>) => boolean;
className?: string;
Expand Down
4 changes: 3 additions & 1 deletion src/components/basic_table/table_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { Action } from './action_types';
import { Primitive } from '../../services/sort/comparators';
import { CommonProps } from '../common';

export type ItemId<T> = string | ((item: T) => string);
export type ItemId<T> = string | number | ((item: T) => string);
export type ItemIdResolved = string | number;

export type EuiTableDataType =
| 'auto'
| 'string'
Expand Down

0 comments on commit a4eecae

Please sign in to comment.