mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
fix double click handler on ItemCard
This commit is contained in:
@@ -126,6 +126,43 @@ const CompactItemCard = ({
|
|||||||
? internalState.isSelected(internalState.extractRowId(data) || '')
|
? internalState.isSelected(internalState.extractRowId(data) || '')
|
||||||
: false;
|
: false;
|
||||||
|
|
||||||
|
const handleClick = useDoubleClick({
|
||||||
|
onDoubleClick: (e: React.MouseEvent<HTMLDivElement>) => {
|
||||||
|
if (!data || !controls || !internalState) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
controls.onDoubleClick?.({
|
||||||
|
event: e,
|
||||||
|
internalState,
|
||||||
|
item: data as any,
|
||||||
|
itemType,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onSingleClick: (e: React.MouseEvent<HTMLDivElement>) => {
|
||||||
|
if (!data || !controls || !internalState) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't trigger selection if clicking on interactive elements
|
||||||
|
const target = e.target as HTMLElement;
|
||||||
|
const isInteractiveElement = target.closest(
|
||||||
|
'button, a, input, select, textarea, [role="button"]',
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isInteractiveElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
controls.onClick?.({
|
||||||
|
event: e,
|
||||||
|
internalState,
|
||||||
|
item: data as any,
|
||||||
|
itemType,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
const handleMouseEnter = () => {
|
const handleMouseEnter = () => {
|
||||||
if (withControls) {
|
if (withControls) {
|
||||||
@@ -139,43 +176,6 @@ const CompactItemCard = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClick = useDoubleClick({
|
|
||||||
onSingleClick: (e: React.MouseEvent<HTMLDivElement>) => {
|
|
||||||
if (!data || !controls || !internalState) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't trigger selection if clicking on interactive elements
|
|
||||||
const target = e.target as HTMLElement;
|
|
||||||
const isInteractiveElement = target.closest(
|
|
||||||
'button, a, input, select, textarea, [role="button"]',
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isInteractiveElement) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
controls.onClick?.({
|
|
||||||
event: e,
|
|
||||||
internalState,
|
|
||||||
item: data as any,
|
|
||||||
itemType,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onDoubleClick: (e: React.MouseEvent<HTMLDivElement>) => {
|
|
||||||
if (!data || !controls || !internalState) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
controls.onDoubleClick?.({
|
|
||||||
event: e,
|
|
||||||
internalState,
|
|
||||||
item: data as any,
|
|
||||||
itemType,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleContextMenu = (e: React.MouseEvent<HTMLDivElement>) => {
|
const handleContextMenu = (e: React.MouseEvent<HTMLDivElement>) => {
|
||||||
if (!data || !controls || !internalState) {
|
if (!data || !controls || !internalState) {
|
||||||
return;
|
return;
|
||||||
@@ -259,6 +259,43 @@ const DefaultItemCard = ({
|
|||||||
? internalState.isSelected(internalState.extractRowId(data) || '')
|
? internalState.isSelected(internalState.extractRowId(data) || '')
|
||||||
: false;
|
: false;
|
||||||
|
|
||||||
|
const handleClick = useDoubleClick({
|
||||||
|
onDoubleClick: (e: React.MouseEvent<HTMLDivElement>) => {
|
||||||
|
if (!data || !controls || !internalState) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
controls.onDoubleClick?.({
|
||||||
|
event: e,
|
||||||
|
internalState,
|
||||||
|
item: data as any,
|
||||||
|
itemType,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onSingleClick: (e: React.MouseEvent<HTMLDivElement>) => {
|
||||||
|
if (!data || !controls || !internalState) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't trigger selection if clicking on interactive elements
|
||||||
|
const target = e.target as HTMLElement;
|
||||||
|
const isInteractiveElement = target.closest(
|
||||||
|
'button, a, input, select, textarea, [role="button"]',
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isInteractiveElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
controls.onClick?.({
|
||||||
|
event: e,
|
||||||
|
internalState,
|
||||||
|
item: data as any,
|
||||||
|
itemType,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
const handleMouseEnter = () => {
|
const handleMouseEnter = () => {
|
||||||
if (withControls) {
|
if (withControls) {
|
||||||
@@ -272,43 +309,6 @@ const DefaultItemCard = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClick = useDoubleClick({
|
|
||||||
onSingleClick: (e: React.MouseEvent<HTMLDivElement>) => {
|
|
||||||
if (!data || !controls || !internalState) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't trigger selection if clicking on interactive elements
|
|
||||||
const target = e.target as HTMLElement;
|
|
||||||
const isInteractiveElement = target.closest(
|
|
||||||
'button, a, input, select, textarea, [role="button"]',
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isInteractiveElement) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
controls.onClick?.({
|
|
||||||
event: e,
|
|
||||||
internalState,
|
|
||||||
item: data as any,
|
|
||||||
itemType,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onDoubleClick: (e: React.MouseEvent<HTMLDivElement>) => {
|
|
||||||
if (!data || !controls || !internalState) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
controls.onDoubleClick?.({
|
|
||||||
event: e,
|
|
||||||
internalState,
|
|
||||||
item: data as any,
|
|
||||||
itemType,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleContextMenu = (e: React.MouseEvent<HTMLDivElement>) => {
|
const handleContextMenu = (e: React.MouseEvent<HTMLDivElement>) => {
|
||||||
if (!data || !controls || !internalState) {
|
if (!data || !controls || !internalState) {
|
||||||
return;
|
return;
|
||||||
@@ -436,6 +436,43 @@ const PosterItemCard = ({
|
|||||||
|
|
||||||
const isDragging = data && internalState ? internalState.isDragging(data.id) : isDraggingLocal;
|
const isDragging = data && internalState ? internalState.isDragging(data.id) : isDraggingLocal;
|
||||||
|
|
||||||
|
const handleClick = useDoubleClick({
|
||||||
|
onDoubleClick: (e: React.MouseEvent<HTMLDivElement>) => {
|
||||||
|
if (!data || !controls || !internalState) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
controls.onDoubleClick?.({
|
||||||
|
event: e,
|
||||||
|
internalState,
|
||||||
|
item: data as any,
|
||||||
|
itemType,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onSingleClick: (e: React.MouseEvent<HTMLDivElement>) => {
|
||||||
|
if (!data || !controls || !internalState) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't trigger selection if clicking on interactive elements
|
||||||
|
const target = e.target as HTMLElement;
|
||||||
|
const isInteractiveElement = target.closest(
|
||||||
|
'button, a, input, select, textarea, [role="button"]',
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isInteractiveElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
controls.onClick?.({
|
||||||
|
event: e,
|
||||||
|
internalState,
|
||||||
|
item: data as any,
|
||||||
|
itemType,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
const handleMouseEnter = () => {
|
const handleMouseEnter = () => {
|
||||||
if (withControls) {
|
if (withControls) {
|
||||||
@@ -449,43 +486,6 @@ const PosterItemCard = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClick = useDoubleClick({
|
|
||||||
onSingleClick: (e: React.MouseEvent<HTMLDivElement>) => {
|
|
||||||
if (!data || !controls || !internalState) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't trigger selection if clicking on interactive elements
|
|
||||||
const target = e.target as HTMLElement;
|
|
||||||
const isInteractiveElement = target.closest(
|
|
||||||
'button, a, input, select, textarea, [role="button"]',
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isInteractiveElement) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
controls.onClick?.({
|
|
||||||
event: e,
|
|
||||||
internalState,
|
|
||||||
item: data as any,
|
|
||||||
itemType,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onDoubleClick: (e: React.MouseEvent<HTMLDivElement>) => {
|
|
||||||
if (!data || !controls || !internalState) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
controls.onDoubleClick?.({
|
|
||||||
event: e,
|
|
||||||
internalState,
|
|
||||||
item: data as any,
|
|
||||||
itemType,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleContextMenu = (e: React.MouseEvent<HTMLDivElement>) => {
|
const handleContextMenu = (e: React.MouseEvent<HTMLDivElement>) => {
|
||||||
if (!data || !controls || !internalState) {
|
if (!data || !controls || !internalState) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user