diff --git a/src/components/List/List.tsx b/src/components/List/List.tsx index c69c77b4d9..56be19fc1b 100644 --- a/src/components/List/List.tsx +++ b/src/components/List/List.tsx @@ -26,13 +26,7 @@ import {getUniqId} from '../utils/common'; import {ListLoadingIndicator} from './ListLoadingIndicator'; import {ListItem, SimpleContainer, defaultRenderItem} from './components'; import {listNavigationIgnoredKeys} from './constants'; -import type { - ItemClickWithEvent, - ListItemData, - ListItemProps, - ListProps, - SimpleItemClick, -} from './types'; +import type {ListItemData, ListItemProps, ListProps} from './types'; import './List.scss'; @@ -254,20 +248,7 @@ export class List extends React.Component, ListState)({ - item: this.state.items[activeItem], - index: activeItem, - event, - fromKeyboard: true, - }); - } else { - (this.props.onItemClick as SimpleItemClick)( - this.state.items[activeItem], - activeItem, - true, - ); - } + this.props.onItemClick(this.state.items[activeItem], activeItem, true, event); } break; } diff --git a/src/components/List/components/ListItem.tsx b/src/components/List/components/ListItem.tsx index c0b5563c9f..fb2a85afd1 100644 --- a/src/components/List/components/ListItem.tsx +++ b/src/components/List/components/ListItem.tsx @@ -9,7 +9,7 @@ import {Icon} from '../../Icon'; import {block} from '../../utils/cn'; import {eventBroker} from '../../utils/event-broker'; import {ListQa} from '../constants'; -import type {ItemClickWithEvent, ListItemProps, SimpleItemClick} from '../types'; +import type {ListItemProps} from '../types'; const b = block('list'); @@ -112,15 +112,7 @@ export class ListItem extends React.Component> { if (!this.props.onClick) { return; } - if (this.props.onClick.length === 1) { - (this.props.onClick as ItemClickWithEvent)({ - item: this.props.item, - index: this.props.itemIndex, - event, - }); - return; - } - (this.props.onClick as SimpleItemClick)(this.props.item, this.props.itemIndex); + this.props.onClick(this.props.item, this.props.itemIndex, false, event); }; private onClickCapture: React.MouseEventHandler = (event) => { diff --git a/src/components/List/types.ts b/src/components/List/types.ts index 851f9ee4a2..b172a04988 100644 --- a/src/components/List/types.ts +++ b/src/components/List/types.ts @@ -11,26 +11,13 @@ export type ListSortParams = {oldIndex: number; newIndex: number}; export type ListItemData = T & {disabled?: boolean}; -export type SimpleItemClick = ( +type ItemClickHandler = ( item: ListItemData, index: number, fromKeyboard?: boolean, + event?: React.MouseEvent | React.KeyboardEvent, ) => void; -export type ItemClickWithEvent = ({ - item, - index, - fromKeyboard, - event, -}: { - item: ListItemData; - index: number; - fromKeyboard?: boolean; - event: React.MouseEvent | React.KeyboardEvent; -}) => void; - -type ItemClickHandler = SimpleItemClick | ItemClickWithEvent; - export type ListProps = QAProps & { items: ListItemData[]; className?: string;