motion
motion copied to clipboard
[BUG] `<Reorder.Group />` stops working if `axis` is changing after window resize
If the axis changes on window resize (detected by matchMedia), <Reorder.Group /> stops reordering and allows only dragging, but the state is not changing.
However, if I change the axis by clicking on a button, and the window size is not changed, it works well.
Reproduction of the bug
https://stackblitz.com/edit/vitejs-vite-7pbqpyha?file=src%2FApp.tsx
Steps to reproduce
Steps to reproduce the behavior:
- Go to https://stackblitz.com/edit/vitejs-vite-7pbqpyha?file=src%2FApp.tsx
- Resize preview
- Drag items
Expected behavior
To work correctly if axis is changed
Video or screenshots
https://github.com/user-attachments/assets/9a8c0b24-c471-4b4d-abbb-659c714cce21
For those who run in same issue, there are workarounds
- add a
keyprop for<Reorder.Group key={axis.toString()} />, this will force component recreation, with all side effects... - use
setTimeoutafter window size changes
Any way this workarounds are just workarounds , and not are solutions.