From f1452fb45f99f8abbe2c7c5a3c8d495ad9d4e323 Mon Sep 17 00:00:00 2001 From: Ankita Kinger Date: Wed, 12 Feb 2025 14:36:16 +0530 Subject: [PATCH] reverting double click changes on entity item --- .../packages/design-system/ads/src/List/List.tsx | 9 +++++++++ .../design-system/ads/src/List/List.types.tsx | 2 ++ .../EditableEntityName/EditableEntityName.tsx | 2 -- .../EditableEntityName/EditableEntityName.types.ts | 2 -- .../EntityExplorer/EntityItem/EntityItem.tsx | 11 ----------- .../EntityExplorer/EntityItem/EntityItem.types.ts | 2 -- 6 files changed, 11 insertions(+), 17 deletions(-) diff --git a/app/client/packages/design-system/ads/src/List/List.tsx b/app/client/packages/design-system/ads/src/List/List.tsx index 2d01eb7f07e7..f066d484efb4 100644 --- a/app/client/packages/design-system/ads/src/List/List.tsx +++ b/app/client/packages/design-system/ads/src/List/List.tsx @@ -105,6 +105,14 @@ function ListItem(props: ListItemProps) { } }); + const handleDoubleClick = useEventCallback((e: React.MouseEvent) => { + e.stopPropagation(); + + if (!props.isDisabled && props.onDoubleClick) { + props.onDoubleClick(); + } + }); + const handleRightControlClick = useEventCallback((e: React.MouseEvent) => { e.stopPropagation(); }); @@ -119,6 +127,7 @@ function ListItem(props: ListItemProps) { data-testid={props.dataTestId} id={props.id} onClick={handleOnClick} + onDoubleClick={handleDoubleClick} role="listitem" size={size} > diff --git a/app/client/packages/design-system/ads/src/List/List.types.tsx b/app/client/packages/design-system/ads/src/List/List.types.tsx index 1f9a2c16fcdf..51f08661d5c3 100644 --- a/app/client/packages/design-system/ads/src/List/List.types.tsx +++ b/app/client/packages/design-system/ads/src/List/List.types.tsx @@ -12,6 +12,8 @@ export interface ListItemProps { rightControlVisibility?: "hover" | "always"; /** callback for when the list item is clicked */ onClick: (e: MouseEvent) => void; + /** callback for when the list item is double-clicked */ + onDoubleClick?: () => void; /** Whether the list item is disabled. */ isDisabled?: boolean; /** Whether the list item is selected. */ diff --git a/app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.tsx b/app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.tsx index 6f50f216297a..b6912488676c 100644 --- a/app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.tsx +++ b/app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.tsx @@ -16,7 +16,6 @@ export const EditableEntityName = (props: EditableEntityNameProps) => { isFixedWidth, isLoading, name, - onDoubleClick, onExitEditing, onNameSave, size = "small", @@ -81,7 +80,6 @@ export const EditableEntityName = (props: EditableEntityNameProps) => { inputRef={inputRef} isEditable={inEditMode} kind={size === "small" ? "body-s" : "body-m"} - onDoubleClick={onDoubleClick} > {editableName} diff --git a/app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.types.ts b/app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.types.ts index 976a0571768f..e51d4350ff6c 100644 --- a/app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.types.ts +++ b/app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.types.ts @@ -23,6 +23,4 @@ export interface EditableEntityNameProps { onNameSave: (name: string) => void; /** Function to validate the name. */ validateName: (name: string) => string | null; - /** callback for when the list item is double-clicked */ - onDoubleClick?: (e: React.MouseEvent) => void; } diff --git a/app/client/packages/design-system/ads/src/Templates/EntityExplorer/EntityItem/EntityItem.tsx b/app/client/packages/design-system/ads/src/Templates/EntityExplorer/EntityItem/EntityItem.tsx index 2a4549a5710a..36654cdd3664 100644 --- a/app/client/packages/design-system/ads/src/Templates/EntityExplorer/EntityItem/EntityItem.tsx +++ b/app/client/packages/design-system/ads/src/Templates/EntityExplorer/EntityItem/EntityItem.tsx @@ -3,7 +3,6 @@ import { ListItem } from "../../../List"; import type { EntityItemProps } from "./EntityItem.types"; import clx from "classnames"; import { EditableEntityName } from "../../EditableEntityName"; -import { useEventCallback } from "usehooks-ts"; export const EntityItem = (props: EntityItemProps) => { const { @@ -19,15 +18,6 @@ export const EntityItem = (props: EntityItemProps) => { const inEditMode = canEdit ? isEditing : false; - const handleDoubleClick = useEventCallback((e: React.MouseEvent) => { - e.preventDefault(); - e.stopPropagation(); - - if (!props.isDisabled && props.onDoubleClick) { - props.onDoubleClick(e); - } - }); - // Use List Item custom title prop to show the editable name const customTitle = useMemo(() => { return ( @@ -38,7 +28,6 @@ export const EntityItem = (props: EntityItemProps) => { isFixedWidth isLoading={isLoading} name={props.title} - onDoubleClick={handleDoubleClick} onExitEditing={onEditComplete} onNameSave={onNameSave} size="medium" diff --git a/app/client/packages/design-system/ads/src/Templates/EntityExplorer/EntityItem/EntityItem.types.ts b/app/client/packages/design-system/ads/src/Templates/EntityExplorer/EntityItem/EntityItem.types.ts index d8c8503d3492..36873a9f422a 100644 --- a/app/client/packages/design-system/ads/src/Templates/EntityExplorer/EntityItem/EntityItem.types.ts +++ b/app/client/packages/design-system/ads/src/Templates/EntityExplorer/EntityItem/EntityItem.types.ts @@ -7,8 +7,6 @@ export interface EntityItemProps > { /** ID of the entity. Will be added to the markup for identification */ id: string; - /** callback for when the list item is double-clicked */ - onDoubleClick?: (e: React.MouseEvent) => void; /** Control the name editing behaviour */ nameEditorConfig: { // Set editable based on user permissions