adobe / react-spectrum

A collection of libraries and tools that help you build adaptive, accessible, and robust user experiences.
https://react-spectrum.adobe.com
Apache License 2.0
12.51k stars 1.08k forks source link

With react-area drag and drop, the keyboard listeners cause all drag/drop zones (and their content) to rerender #6669

Open dsoffer opened 1 month ago

dsoffer commented 1 month ago

Provide a general summary of the issue here

When using useDrag when one clicks the mouse and then the keyboard and alternate in this pattern, the hook event listeners (keyup/keydown) will cause the whole dragzone to rerender, this can cause performance issues

๐Ÿค” Expected Behavior?

I would expect for these zones not to rerender, atleast give me an option to disable the keyboard listeners when using useDrag

๐Ÿ˜ฏ Current Behavior

The drag/drop zones and their content get rerendered

๐Ÿ’ Possible Solution

Ability to turn off keyboard listeners when using useDrag

๐Ÿ”ฆ Context

This is affecting me because it rerenders everything inside the drop container, and it can cause lag when there is a lot of content in there (even though the content is memoed it still rerenders the whole thing)

๐Ÿ–ฅ๏ธ Steps to Reproduce

go to the sample drag and drop part in the documentation https://react-spectrum.adobe.com/react-aria/useDrag.html , put up the profiler to high light rerenders, alternate clicking mouse + pressing a keyboard key. You will see the drag/drop zones rerender everytime

Version

3.6

What browsers are you seeing the problem on?

Firefox, Chrome

If other, please specify.

No response

What operating system are you using?

MACOS

๐Ÿงข Your Company/Team

No response

๐Ÿ•ท Tracking Issue

No response

LFDanLu commented 1 month ago

I believe https://github.com/adobe/react-spectrum/issues/2403 is the root cause for this issue. What use case have you observed this performance hit with?

dsoffer commented 1 month ago

When the drop zones have a lot of thigns to render , which it does in our case at times, it re renders all of it which causes performance issues