mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 04:20:12 +02:00
handle non-list items contextmenu in controls
This commit is contained in:
@@ -183,11 +183,12 @@ const CompactItemCard = ({
|
||||
};
|
||||
|
||||
const handleContextMenu = (e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (!data || !controls || !internalState) {
|
||||
if (!data || !controls) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
controls.onMore?.({
|
||||
event: e,
|
||||
internalState,
|
||||
@@ -337,11 +338,12 @@ const DefaultItemCard = ({
|
||||
};
|
||||
|
||||
const handleContextMenu = (e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (!data || !controls || !internalState) {
|
||||
if (!data || !controls) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
controls.onMore?.({
|
||||
event: e,
|
||||
internalState,
|
||||
@@ -536,11 +538,12 @@ const PosterItemCard = ({
|
||||
};
|
||||
|
||||
const handleContextMenu = (e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (!data || !controls || !internalState) {
|
||||
if (!data || !controls) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
controls.onMore?.({
|
||||
event: e,
|
||||
internalState,
|
||||
|
||||
@@ -232,10 +232,18 @@ export const useDefaultItemListControls = (args?: UseDefaultItemListControlsArgs
|
||||
},
|
||||
|
||||
onMore: ({ event, internalState, item, itemType }: DefaultItemControlProps) => {
|
||||
if (!item || !internalState || !event) {
|
||||
if (!item || !event) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If no internalState, call ContextMenuController directly
|
||||
if (!internalState) {
|
||||
return ContextMenuController.call({
|
||||
cmd: { items: [item] as any[], type: itemType as any },
|
||||
event,
|
||||
});
|
||||
}
|
||||
|
||||
const rowId = internalState.extractRowId(item);
|
||||
|
||||
if (!rowId) return;
|
||||
|
||||
Reference in New Issue
Block a user