fix: Media Explorer canvas wheel dùng native non-passive listener

This commit is contained in:
2026-08-02 20:57:05 +07:00
parent e88ce2e3ea
commit a0b6110fd1
3 changed files with 22 additions and 3 deletions
+12 -1
View File
@@ -9126,6 +9126,18 @@ const MediaExplorerPanel = ({ height, clipboardRef }) => {
setZoom(prev => Math.max(0.2, prev / zoomFactor));
}
};
// React attaches onWheel passively at the root, so e.preventDefault() there is
// ignored and Chrome logs "Unable to preventDefault inside passive event listener".
// Use a native non-passive wheel listener so page scroll is actually blocked.
const handleCanvasWheelRef = React.useRef(handleCanvasWheel);
handleCanvasWheelRef.current = handleCanvasWheel;
React.useEffect(() => {
const canvas = canvasRef.current;
if (!canvas) return;
const h = (e) => handleCanvasWheelRef.current(e);
canvas.addEventListener('wheel', h, { passive: false });
return () => canvas.removeEventListener('wheel', h);
}, []);
const handleCanvasMouseDown = (e) => {
if (!selected) return;
@@ -10509,7 +10521,6 @@ const MediaExplorerPanel = ({ height, clipboardRef }) => {
onMouseMove={handleCanvasMouseMove}
onMouseUp={handleCanvasMouseUp}
onContextMenu={handleCanvasContextMenu}
onWheel={handleCanvasWheel}
></canvas>
{/* FLOATING ZOOM CONTROLS */}