react-native-rich-editor: Editor doesn't scroll to cursor when entering new lines
When entering many new lines, the cursor goes beyond the view.
The expected behavior would be to have the editor always scroll to the cursor position.
Here is a video of the issue:
So one solution I have come up with is to add the following code to the Scroll View wrapping the editor:
<ScrollView
{...}
ref={ref => this.scrollView = ref}
onContentSizeChange={(contentWidth, contentHeight) => {
this.scrollView.scrollToEnd({ animated: false });
}}
>
So now when entering new lines, the scroll view always scrolls to the end, and thus showing the cursor.
But now, there still is another problem. After entering many lines, and then deleting the lines, the cursor goes beyond the scroll view.
Here is a video showing the issue:
I would appreciate if anyone has any feedback about this or knows how to solve this.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (1 by maintainers)
I managed to make the scroll work correctly, making the content absolute, I leave here an example of the main code, and a video to demonstrate, it may be useful for someone else:
https://user-images.githubusercontent.com/15730525/113488977-545a5980-94b9-11eb-8dff-bfdfb010d5ef.mp4
Similar Issue #114
Do u face with this issue. when u select setBold or setItalic, html will auto break into new line in android ? if this happens, try to remove
display: flex; flex-direction: column;@amaralflavio I forgot I had wrapped mine in a scrollview, that was my issue! Thank you so much
saved me !. Thanks a lot
@Andrea-Arguello it should be 100% height since it’s position absolute top: 0; and bottom: 0, if you have a view wrapping the editor make sure it is flex: 1, and the editor also, don’t wrap it in a scroll view
How do you make it work inside a
<ScrollView>?But you are obligated to use a ScrollView? How can you make it work without a scrollview and still obtaining scroll inside the rich editor? That’s the case in the example code as well: https://github.com/wxik/react-native-rich-editor#a-complete-example-using-a-functional-component
@ddikodroid it may be related to the editor’s version, I don’t know, but supposedly from @stulip comment this problem is already solved.