fix(refboard): restore drag-drop with fallback + React event handlers

- Add onDragOver/onDrop preventDefault on container div (React level)
  to always block browser default file-open behavior
- Add DOM fallback in useCanvasSetup if ref is somehow null
- setupDragDrop's native listeners handle the actual upload logic
This commit is contained in:
Hiren Kangad
2026-03-10 11:22:36 +05:30
parent 205ce65a8b
commit ae050d2119
2 changed files with 7 additions and 2 deletions
+6 -1
View File
@@ -253,7 +253,12 @@ export function useCanvasSetup(deps: CanvasSetupDeps) {
// Setup drag/drop and paste
if (!isPublicView || user) {
const dropTarget = canvasContainerRef.current;
// Use the ref first, fall back to DOM query for the canvas parent
let dropTarget: HTMLElement | null = canvasContainerRef.current;
if (!dropTarget) {
const canvasEl = document.querySelector('canvas');
dropTarget = canvasEl?.parentElement ?? null;
}
if (dropTarget) {
dropCleanupRef.current = setupDragDrop(dropTarget, viewport, scene, resolvedBoardId, onCanvasChange);
}
+1 -1
View File
@@ -474,7 +474,7 @@ export default function Editor({ isPublicView }: EditorProps) {
/>}
{/* Canvas */}
<div ref={canvasContainerRef} style={{ flex: 1, position: 'relative', overflow: 'hidden', background: '#1e1e1e' }} onContextMenu={handleContextMenu}>
<div ref={canvasContainerRef} style={{ flex: 1, position: 'relative', overflow: 'hidden', background: '#1e1e1e' }} onContextMenu={handleContextMenu} onDragOver={(e) => e.preventDefault()} onDrop={(e) => e.preventDefault()}>
{/* Dot grid — behind transparent canvas */}
{showGrid && (() => {
const scale = canvasTransform[0] || 1;