From 21d98afd05f306a8168b8994d7476dbe044dfea5 Mon Sep 17 00:00:00 2001 From: Eric Olkowski Date: Wed, 23 Nov 2022 13:10:55 -0500 Subject: [PATCH] Removed deprecated props/logic from remaining components --- .../DataList/DataListDragButton.tsx | 26 +++++------ .../src/components/DataList/DataListItem.tsx | 43 +------------------ 2 files changed, 11 insertions(+), 58 deletions(-) diff --git a/packages/react-core/src/components/DataList/DataListDragButton.tsx b/packages/react-core/src/components/DataList/DataListDragButton.tsx index d1b00bf1baf..55000ed0d46 100644 --- a/packages/react-core/src/components/DataList/DataListDragButton.tsx +++ b/packages/react-core/src/components/DataList/DataListDragButton.tsx @@ -2,7 +2,6 @@ import * as React from 'react'; import { css } from '@patternfly/react-styles'; import styles from '@patternfly/react-styles/css/components/DataList/data-list'; import GripVerticalIcon from '@patternfly/react-icons/dist/esm/icons/grip-vertical-icon'; -import { DataListContext } from './DataList'; export interface DataListDragButtonProps extends React.HTMLProps { /** Additional classes added to the drag button */ @@ -18,20 +17,15 @@ export const DataListDragButton: React.FunctionComponent ( - - {({ dragKeyHandler }) => ( - - )} - + ); DataListDragButton.displayName = 'DataListDragButton'; diff --git a/packages/react-core/src/components/DataList/DataListItem.tsx b/packages/react-core/src/components/DataList/DataListItem.tsx index b823319f6c5..b9a320cb847 100644 --- a/packages/react-core/src/components/DataList/DataListItem.tsx +++ b/packages/react-core/src/components/DataList/DataListItem.tsx @@ -3,7 +3,6 @@ import { css } from '@patternfly/react-styles'; import styles from '@patternfly/react-styles/css/components/DataList/data-list'; import { DataListContext } from './DataList'; import { KeyTypes } from '../../helpers/constants'; -import { DataListDragButton, DataListDragButtonProps } from './DataListDragButton'; export interface DataListItemProps extends Omit, 'children' | 'ref'> { /** Flag to show if the expanded content of the DataList item is visible */ @@ -25,25 +24,6 @@ export interface DataListItemChildProps { rowid: string; } -function findDataListDragButton(node: React.ReactNode): React.ReactElement | null { - if (!React.isValidElement(node)) { - return null; - } - if (node.type === DataListDragButton) { - return node as React.ReactElement; - } - if (node.props.children) { - for (const child of React.Children.toArray(node.props.children)) { - const button = findDataListDragButton(child); - if (button) { - return button; - } - } - } - - return null; -} - export class DataListItem extends React.Component { static displayName = 'DataListItem'; static defaultProps: DataListItemProps = { @@ -65,16 +45,7 @@ export class DataListItem extends React.Component { } = this.props; return ( - {({ - isSelectable, - selectedDataListItemId, - updateSelectedDataListItem, - selectableRow, - isDraggable, - dragStart, - dragEnd, - drop - }) => { + {({ isSelectable, selectedDataListItemId, updateSelectedDataListItem, selectableRow }) => { const selectDataListItem = (event: React.MouseEvent) => { let target: any = event.target; while (event.currentTarget !== target) { @@ -98,17 +69,6 @@ export class DataListItem extends React.Component { } }; - // We made the DataListDragButton determine if the entire item is draggable instead of - // DataListItem like we should have. - // Recursively search children for the DataListDragButton and see if it's disabled... - const dragButton = findDataListDragButton(children); - const dragProps = isDraggable && { - draggable: dragButton ? !dragButton.props.isDisabled : true, - onDrop: drop, - onDragEnd: dragEnd, - onDragStart: dragStart - }; - const isSelected = selectedDataListItemId === id; const selectableInputAriaProps = selectableInputAriaLabel @@ -129,7 +89,6 @@ export class DataListItem extends React.Component { {...(isSelectable && { tabIndex: 0, onClick: selectDataListItem, onKeyDown })} {...(isSelectable && isSelected && { 'aria-selected': true })} {...props} - {...dragProps} > {selectableRow && (