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:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user