Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add stopPropagation calls to dnd handlers #438

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ export const MRT_TableBodyRowGrabHandle = <TData extends MRT_RowData>({
};

const handleDragStart = (event: DragEvent<HTMLButtonElement>) => {
event.stopPropagation();
actionIconProps?.onDragStart?.(event);
event.dataTransfer.setDragImage(rowRef.current as HTMLElement, 0, 0);
table.setDraggingRow(row as any);
};

const handleDragEnd = (event: DragEvent<HTMLButtonElement>) => {
event.stopPropagation();
actionIconProps?.onDragEnd?.(event);
table.setDraggingRow(null);
table.setHoveredRow(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const MRT_TableHeadCellGrabHandle = <TData extends MRT_RowData>({
};

const handleDragStart = (event: DragEvent<HTMLButtonElement>) => {
event.stopPropagation();
actionIconProps?.onDragStart?.(event);
setDraggingColumn(column);
event.dataTransfer.setDragImage(
Expand All @@ -51,6 +52,7 @@ export const MRT_TableHeadCellGrabHandle = <TData extends MRT_RowData>({
};

const handleDragEnd = (event: DragEvent<HTMLButtonElement>) => {
event.stopPropagation();
actionIconProps?.onDragEnd?.(event);
if (hoveredColumn?.id === 'drop-zone') {
column.toggleGrouping();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,22 @@ export const MRT_ShowHideColumnsMenuItems = <TData extends MRT_RowData>({
const [isDragging, setIsDragging] = useState(false);

const handleDragStart = (e: DragEvent<HTMLButtonElement>) => {
e.stopPropagation();
setIsDragging(true);
e.dataTransfer.setDragImage(menuItemRef.current as HTMLElement, 0, 0);
};

const handleDragEnd = (_e: DragEvent<HTMLButtonElement>) => {
const handleDragEnd = (e: DragEvent<HTMLButtonElement>) => {
e.stopPropagation();
setIsDragging(false);
setHoveredColumn(null);
if (hoveredColumn) {
setColumnOrder(reorderColumn(column, hoveredColumn, columnOrder));
}
};

const handleDragEnter = (_e: DragEvent) => {
const handleDragEnter = (e: DragEvent) => {
e.stopPropagation();
if (!isDragging && columnDef.enableColumnOrdering !== false) {
setHoveredColumn(column);
}
Expand Down