cjwirth / RichEditorView

RichEditorView is a simple, modular, drop-in UIView subclass for Rich Text Editing.
BSD 3-Clause "New" or "Revised" License
1.9k stars 445 forks source link

relativeCaretYPosition returns 0 on new line #169

Open the-old-one opened 6 years ago

the-old-one commented 6 years ago

If the cursor is in the middle or at the start of a word, relativeCaretYPosition returns 0 when Return pressed.

As a result, the view does not follow the cursor.

It happens because runJS("RE.getRelativeCaretYPosition();") in this case returns NaN.

To reproduce: Run RichEditorViewSample, select Swift or Objective-C, type any character, move the cursor to the start of the line, press "return" till the cursor disappears below the bottom edge of the view. The view will not scroll.

Expected behaviour: The view scrolls to show the cursor. richeditorview

Tested on iOS 11.

the-old-one commented 6 years ago

I believe I fixed the issue. Please check the linked commit.

The problem was happening when editing a text node.

paresh-navadiya commented 5 years ago

Its not solved yet as its easy reproducible if editor's isScrollEnabled is false