-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Click and hold to select text using a text component #13938
Comments
Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally! If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:
If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution. |
This is still reproducible with |
@hramos Could you please reopen that? |
Adding selectable={true} or selectable is not working. |
For me, both platforms are existing different problems : In IOS, adding selectable={true} or selectable is not working for selecting partially text |
I really need this feature... I'm on 0.52 v and I only can see "Copy" but not the expected behavior as it is said. Someone knows if there is a way to do so? |
@pausabe If you really want this and you dont have complex nested component in Text component. Just using TextInput instead of Text and pass editable={false} as the prop and set the padding and margin as 0. The behavior is just same as Text but selectable. Hope this help. |
Thanks @tikkichan4! I've tried this in a simple text with the editable={false} but the text is not selectable... |
I think this feature is necessary. |
+1 |
@yasemincidem Have you found a solution? |
This issue looks like a question and not an actual bug report. Please try asking over on Stack Overflow instead. |
Hello guys, |
@BichCNTT you can try this status-im/status-mobile#3616 |
@react-native-bot this issue should be reopened |
Summary: On iOS, it is not possible to select a range of text using a `Text` component (see #13938). Because of how the `Text` component is implemented on iOS, this will not work without a complete re-write. On Android however, this is not an issue. As the `TextInput` component has evolved, it can more or less be used as a drop-in replacement on iOS by setting `multiline={true}` and `editable={false}`. Except for one detail: the text input field has scrolling activated and it's not possible to turn off. (See #1391 and #15962). This pull request addresses that issue, simply by exposing the `scrollEnabled` property: ``` <TextInput multiline editable={false} scrollEnabled={false} /> ``` 1. Create a multiline `TextInput` component, with the attributes presented above. 2. Run on iOS 3. The `TextInput` field should not be able to scroll facebook/react-native-website#367 [IOS] [FEATURE] [TextInput] - Made it possible to turn off scrolling on a multiline TextInput component Pull Request resolved: #19330 Differential Revision: D9235061 Pulled By: hramos fbshipit-source-id: 99d278004fc236b47dde7e61d74c71e8a3b9d170
Summary: On iOS, it is not possible to select a range of text using a `Text` component (see #13938). Because of how the `Text` component is implemented on iOS, this will not work without a complete re-write. On Android however, this is not an issue. As the `TextInput` component has evolved, it can more or less be used as a drop-in replacement on iOS by setting `multiline={true}` and `editable={false}`. Except for one detail: the text input field has scrolling activated and it's not possible to turn off. (See #1391 and #15962). This pull request addresses that issue, simply by exposing the `scrollEnabled` property: ``` <TextInput multiline editable={false} scrollEnabled={false} /> ``` 1. Create a multiline `TextInput` component, with the attributes presented above. 2. Run on iOS 3. The `TextInput` field should not be able to scroll facebook/react-native-website#367 [IOS] [FEATURE] [TextInput] - Made it possible to turn off scrolling on a multiline TextInput component Pull Request resolved: #19330 Differential Revision: D9235061 Pulled By: hramos fbshipit-source-id: 99d278004fc236b47dde7e61d74c71e8a3b9d170
+1 |
2 similar comments
+1 |
+1 |
I've published a workaround for now if you're interested: https://github.com/msand/react-native-selectable-text It's only needed on Android, and works as a drop-in replacement for a TextInput with these specific values on iOS, as TextInput with editable: false already works correctly there. TextInput on Android either fills most of the screen with the keyboard, or disables the ability to select and respond to selection changes. I would assume this component only works well for the specific use-case I had, haven't tested it for any other prop values. import SelectableText from 'react-native-selectable-text';
export default ({ text, onSelectionChange }) => (
<SelectableText
selectable
multiline
contextMenuHidden
scrollEnabled={false}
editable={false}
onSelectionChange={onSelectionChange}
style={{
color: "#BAB6C8",
}}
value={text}
/>); |
My solution is to use https://www.npmjs.com/package/react-native-webview-autoheight and load text as html. |
React-Native 0.59 version. Only show COPY when long press. |
Use a import { Platform } from 'react-native';
// ...
{Platform.OS === 'ios' ? (
// iOS requires a textinput for word selections
<TextInput
value={description}
editable={false}
multiline
/>
) : (
// Android can do word selections just with <Text>
<Text selectable>{description}</Text>
)} |
I test version 0.59.10 but |
@scarlac |
@acro5piano TextInput cannot be nested in another TextInput. Un-nest your texts to make them selectable. If you need rich text formatting I unfortunately don't have an answer. @hoanvnbka |
@scarlac |
Hello, Thanks for the issue. I have been contributing to facebook/react-native for 4 years and specialize in the Text/TextInput components. I currently have 58 facebook/react-native PRs: https://github.com/facebook/react-native/pulls?q=is%3Apr+author%3Afabriziobertoglio1987+ It is the suggested approach from the react-native core team (see this discussion). I'm publishing several fixes for Text and TextInput component in a separate library react-native-improved.
The advantages would be:
Do you want me to publish for you a patched release? I'm working on a list of priorities. Thanks |
@scarlac Are you aware of a way to make the |
@johnlahut i'am not currently aware of a method but I haven't checked since that post so perhaps there are ways now that I'm not aware of. If you find one please share. |
This worked for me. Thanks 👍 . For me adding |
Dropping this here https://github.com/bluesky-social/react-native-uitextview This works (mostly, it's a WIP but also not much time to fully implement everything) on iOS for text selection. Uses RN Contribs are more than welcome if you want to clean it up! Some styles are missing, etc. right now. @fabOnReact Totally feel free to take it and clean it up if you ever want to. From what I've seen you do a lot of good work with |
In our case we need to have text formatting, and because the value of a |
surprised & devastated that this is not a react native feature :( |
Hello @cipolleschi , @cortinico, I debugged the partial text selection issue because it intrigued me, especially since it’s been open since 2017. Here are my findings:
Possible Solution
Cons
I created a sample app showcasing all major combinations of selectable texts:
Sample - https://github.com/PrinceK001/RNPlayground Could you please validate my understanding? |
@cortinico, @cipolleschi, there is another issue reported citing the exact same behaviour. Looking forward to hear your opinion and conclude this issue. |
Description
I want click-and-hold-to-select-text using a Text component and then i searched it and i found
selectable
property.It good works but it copy the entire text field.I want to selecting a subset of the text field for copying.Actually this question is asked on stackoverflow .Here is question on stackoverflow:http://stackoverflow.com/a/37119619/4596143Reproduction Steps and Sample Code
I try this code block:
This full of text ("text description") can copy not partially .I want to it like screenshot
Actual behaviour:
Expected behavior:
Solution
They are said that RN 0.39 adds support to copy the entire text field, but does not yet include support for selecting a subset of the text field for copying on stackoverflow .I wonder
Text
component include support for selecting a subset of the text field for copying on new versions for react native.If the property does not exist on new versions ,will the property for text integrate ?Additional Information
The text was updated successfully, but these errors were encountered: