-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PointerEvents="none" not working as expected on text elements #1741
Comments
I just forgot about selectable={false} on elements which is implemented already! However it would still be nice to have the same behaviour on the web but less important as I first thought :) |
That's right, you can disable text selection as needed. I think React Native gets text selection wrong by default and produces inaccessible experiences, especially on web. It looks like it also has a different relationship between One thing we should do though, is make it so that this works: <Text selectable={false}>Some <Text selectable={true}>text</Text></Text> |
I agree this is more or less a bug in React Native! -> on the nested text I did a little expirement: user-select: text; works fine but user-select: auto; not. I'll make a PR for this |
Based on this comment: necolas#1741 (comment)
Closing this as for nested elements there is a PR up: #1742. But maybe we could document this differente somewhere for library owners so they can make web support better (e.g. set selectable={false} inside elements on buttons |
* Make text non-selectable on web too Context: necolas/react-native-web#1741 * Add default of selectable=false to have the same behaviour across platforms * Fix prettier of icon-button.js Co-authored-by: Joel Arvidsson <[email protected]>
The problem
I'm building a time picker component for React Native Paper with the PanResponder (which works great on the web!)
But I would expect the pointerEvents="none" to prevent the children from selecting text. But it does not. On iOS and Android text selection does not work in views with pointerEvents="none" even when the selectable={true} is used on
How to reproduce
Simplified test case: https://codesandbox.io/s/bold-shape-efdkb?file=/src/App.js
Steps to reproduce:
Expected behavior
I think we should add userSelect: 'none' (https://developer.mozilla.org/en-US/docs/Web/CSS/user-select) to the css when pointerEvents="none" is used. This way text inside buttons won't be selected if they have the pointerEvents disabled
Environment (include versions). Did this work in previous versions?
Additional context
react-native-web/packages/react-native-web/src/modules/createDOMProps/index.js
Line 38 in 9ed9231
https://github.com/necolas/react-native-web/blob/master/packages/react-native-web/src/exports/StyleSheet/compile.js#L150
The text was updated successfully, but these errors were encountered: