Skip to content

Commit

Permalink
reverting double click changes on entity item
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitakinger committed Feb 12, 2025
1 parent 29ad43c commit f1452fb
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 17 deletions.
9 changes: 9 additions & 0 deletions app/client/packages/design-system/ads/src/List/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand All @@ -119,6 +127,7 @@ function ListItem(props: ListItemProps) {
data-testid={props.dataTestId}
id={props.id}
onClick={handleOnClick}
onDoubleClick={handleDoubleClick}
role="listitem"
size={size}
>
Expand Down
2 changes: 2 additions & 0 deletions app/client/packages/design-system/ads/src/List/List.types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const EditableEntityName = (props: EditableEntityNameProps) => {
isFixedWidth,
isLoading,
name,
onDoubleClick,
onExitEditing,
onNameSave,
size = "small",
Expand Down Expand Up @@ -81,7 +80,6 @@ export const EditableEntityName = (props: EditableEntityNameProps) => {
inputRef={inputRef}
isEditable={inEditMode}
kind={size === "small" ? "body-s" : "body-m"}
onDoubleClick={onDoubleClick}
>
{editableName}
</Styled.Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 (
Expand All @@ -38,7 +28,6 @@ export const EntityItem = (props: EntityItemProps) => {
isFixedWidth
isLoading={isLoading}
name={props.title}
onDoubleClick={handleDoubleClick}
onExitEditing={onEditComplete}
onNameSave={onNameSave}
size="medium"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f1452fb

Please sign in to comment.