Skip to content

Commit ac317c5

Browse files
citizensasSassoun Derderian
andauthored
fix(#1075): groupHeader action click event triggers twice (#1078)
Co-authored-by: Sassoun Derderian <[email protected]>
1 parent e7d8fce commit ac317c5

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

packages/core/src/data-editor/stories/data-editor.stories.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,3 +711,32 @@ export const SimpleEditable = () => {
711711
/>
712712
);
713713
};
714+
715+
export function GroupHeaderActionClick() {
716+
const cols = [
717+
{ title: "Col1", width: 100, grow: 1, group: "Group"},
718+
];
719+
720+
const [clickCount, setClickCount] = useState(0);
721+
722+
return (
723+
<div>
724+
<h3>Click count: {clickCount}</h3>
725+
<DataEditor
726+
width={500}
727+
height={500}
728+
rows={0}
729+
columns={cols}
730+
getCellContent={() => ({ kind: GridCellKind.Text, data: '', displayData: '',allowOverlay: false })}
731+
getGroupDetails={(name) => ({
732+
name,
733+
actions: [{
734+
icon: 'headerString',
735+
title: "Action",
736+
onClick: (e) => setClickCount(c => c + 1 ),
737+
}]
738+
})}
739+
/>
740+
</div>
741+
);
742+
}

packages/core/src/internal/data-grid/data-grid.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ const DataGrid: React.ForwardRefRenderFunction<DataGridRef, DataGridProps> = (p,
959959
: headerHovered || clickableInnerCellHovered || editableBoolHovered || groupHeaderHovered
960960
? "pointer"
961961
: "default";
962-
962+
963963
const style = React.useMemo(
964964
() => ({
965965
// width,
@@ -1219,11 +1219,6 @@ const DataGrid: React.ForwardRefRenderFunction<DataGridRef, DataGridProps> = (p,
12191219
onHeaderIndicatorClick?.(col, headerBounds.bounds);
12201220
}
12211221
}
1222-
} else if (args.kind === groupHeaderKind) {
1223-
const action = groupHeaderActionForEvent(args.group, args.bounds, args.localEventX, args.localEventY);
1224-
if (action !== undefined && args.button === 0) {
1225-
action.onClick(args);
1226-
}
12271222
}
12281223
},
12291224
[
@@ -1232,7 +1227,6 @@ const DataGrid: React.ForwardRefRenderFunction<DataGridRef, DataGridProps> = (p,
12321227
isOverHeaderElement,
12331228
onHeaderMenuClick,
12341229
onHeaderIndicatorClick,
1235-
groupHeaderActionForEvent,
12361230
]
12371231
);
12381232
useEventListener("click", onClickImpl, windowEventTarget, false);

0 commit comments

Comments
 (0)