Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit e6f1eb9

Browse files
committed
fix DnD incompatibility with obsidian
1 parent 9c203e4 commit e6f1eb9

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/components/Table.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export function Table(tableData: TableDataType) {
9191
);
9292
const [persistSizingTimeout, setPersistSizingTimeout] = React.useState(null);
9393
// Drag and drop
94+
const DnDRef = React.useRef(null);
9495
const [columnOrder, setColumnOrder] = React.useState<ColumnOrderState>(
9596
columns.map((c) => c.id)
9697
);
@@ -315,10 +316,13 @@ export function Table(tableData: TableDataType) {
315316
<div
316317
key={`${headerGroup.id}-${headerGroupIndex}`}
317318
className={`${c("tr header-group")}`}
319+
ref={DnDRef}
318320
>
319321
<DndProvider
320322
key={`${headerGroup.id}-${headerGroupIndex}-dnd-provider`}
321323
backend={HTML5Backend}
324+
debugMode={global.enable_debug_mode}
325+
context={DnDRef}
322326
>
323327
{headerGroup.headers
324328
.filter(

src/components/TableHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default function TableHeader(headerProps: TableHeaderProps) {
3535
view.diskConfig.reorderColumns(newColumnOrder);
3636
}
3737

38-
const [{ isDragging, handlerId }, drag] = useDrag(
38+
const [{ isDragging, handlerId }, drag, dragPreview] = useDrag(
3939
() => ({
4040
type: DnDConfiguration.DRAG_TYPE,
4141
item: { id, originalIndex },

src/helpers/Constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export const CellSizeOptions = Object.freeze({
218218
})
219219

220220
export const DnDConfiguration = Object.freeze({
221-
DRAG_TYPE: "column",
221+
DRAG_TYPE: "dbFolderColumn",
222222
});
223223

224224
export const ResizeConfiguration = Object.freeze({

0 commit comments

Comments
 (0)