Skip to content
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

CSS lineClamp disables text selection on Android #136

Open
necolas opened this issue Jun 11, 2024 · 0 comments
Open

CSS lineClamp disables text selection on Android #136

necolas opened this issue Jun 11, 2024 · 0 comments
Labels
bug: react-native A bug that originates in React Native bug Something isn't working

Comments

@necolas
Copy link
Contributor

necolas commented Jun 11, 2024

Describe the issue

Root cause is a bug in React Native for Android (iOS works correctly). When userSelect:'auto' or selectable={true} is used in combination with numberOfLines on a React Native Text, Android clips overflow text rather than using the default ellipsizeMode:'tail'.

The workaround to restore the text overflow ellipsis is to set userSelect:'none' on the text for Android, which comes at the cost of text no longer being selectable.

Expected behavior

Text should be truncated with an ellipsis and remain user-selectable.

Steps to reproduce

React Native 0.75 or below. Android.

  • <html.span>
  • style of lineClamp
  • text is no longer selectable

Test case

https://snack.expo.dev/rIIwaSlqQ6cHKlcO2Vatn?platform=android

Additional comments

Android hack to fix this https://stackoverflow.com/questions/14691511/textview-using-spannable-ellipsize-doesnt-work/40505388#40505388

@necolas necolas added bug Something isn't working bug: react-native A bug that originates in React Native labels Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: react-native A bug that originates in React Native bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant