motion icon indicating copy to clipboard operation
motion copied to clipboard

[BUG] `<Reorder.Group />` stops working if `axis` is changing after window resize

Open Profesor08 opened this issue 10 months ago • 1 comments

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:

  1. Go to https://stackblitz.com/edit/vitejs-vite-7pbqpyha?file=src%2FApp.tsx
  2. Resize preview
  3. 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

Profesor08 avatar Jan 23 '25 14:01 Profesor08

For those who run in same issue, there are workarounds

  • add a key prop for <Reorder.Group key={axis.toString()} />, this will force component recreation, with all side effects...
  • use setTimeout after window size changes

Any way this workarounds are just workarounds , and not are solutions.

Profesor08 avatar Jan 23 '25 14:01 Profesor08