react-spectrum icon indicating copy to clipboard operation
react-spectrum copied to clipboard

useLongPress always disables user-select

Open Pagebakers opened this issue 1 year ago โ€ข 3 comments

Provide a general summary of the issue here

I'm using useLongPress with in a custom context menu component to support touch devices. Now when the longPressProps are passed to the container element, text can no longer be selected. usePress has an option to enable it, but this is not accepted by the useLongPress hook.

๐Ÿค” Expected Behavior?

Allow to set allowTextSelectionOnPress on the useLongPress hook

๐Ÿ˜ฏ Current Behavior

allowTextSelectionOnPress not supported

๐Ÿ’ Possible Solution

No response

๐Ÿ”ฆ Context

No response

๐Ÿ–ฅ๏ธ Steps to Reproduce

Reproduction: https://storybook.saas-ui.dev/?path=/story/components-overlay-contextmenu--basic

Code: https://github.com/saas-js/saas-ui/blob/main/packages/saas-ui-core/src/menu/context-menu.tsx#L55

Version

"@react-aria/interactions": "^3.21.1",

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

Mac OS

๐Ÿงข Your Company/Team

No response

๐Ÿ•ท Tracking Issue

No response

Pagebakers avatar Apr 18 '24 08:04 Pagebakers

Seems like a reasonable addition, but we'll have to test how this behaves on touch devices.

reidbarber avatar Apr 18 '24 14:04 reidbarber

These gestures directly conflict though. Long press is the gesture to select text on iOS. So if you're doing a different action on long press, I'm not sure it makes sense to also select text. You probably want either one or the other.

devongovett avatar Apr 18 '24 19:04 devongovett

That makes sense, the idea is also to only allow selection on mouse input devices. But perhaps there is a better way to check the device type in the touch event?

Pagebakers avatar Apr 22 '24 15:04 Pagebakers