Open andylwelch opened 1 month ago
I'm also facing this issue. I made a reproduction of it here (though I initially suspected multi-backend to be at fault): https://github.com/vezaynk/dnd-vite-issue-demo
Thanks for the reproduction @vezaynk. Glad this issue was useful for someone!
Describe the bug Building my repository with
vite
I always encounter an issue that while dragging an item in a scroll zone that the scroll also moves to match the drag (e.g. stays in the same position!).Everything works fine running via
vite dev
.After many hours of hunting in the code I realised that the default treeshaking removes
{ passive: false }
in thereact-dnd-touch-backend/dist/TouchBackendImpl.js
fileFor example this is the code after treeshaking; instead of the following with treeshaking disabled;
Without this
{ passive: false }
thee1.preventDefault()
in thethis.handleTopMove = (e1)=>{
function is unable to stop the default scroll behaviour;Reproduction
Steps to reproduce the behavior:
Expected behavior While dragging the touch scroll to be prevented.
Screenshots
Desktop (please complete the following information):
Additional context I fixed this problem by copying the entire
dist
folder to mysrc
code and using the copy instead. Note that I did not have to change any code to fix this issue. I suspect that thevite
=>esbuild
/'rollup' compiler is incorrectly assuming there are nosideEffects
and is removing the followingPerhaps we could rename the constant
supportsPassive
to agetSupportsPassive
function which can be run insideTouchBackendImpl
and shouldnt be removed by treeshaking?