gutenberg-mobile icon indicating copy to clipboard operation
gutenberg-mobile copied to clipboard

Undo/redo: cursor positioning on Rich Text-based blocks after undoing is pos+1

Open mzorz opened this issue 6 years ago • 13 comments
trafficstars

  1. insert a character in the middle of a word, for example place the cursor after "Wel" in "Wel|come to Gutenberg" and tap space
  2. tap undo
  3. observe the action is undone, but the cursor appears one character more to the right than initially, that is in "Welc|ome to Gutenberg"

mzorz avatar Nov 30 '18 12:11 mzorz

OK, this got worse. Instead of the cursor moving, the whole text disappears

koke avatar Apr 04 '19 17:04 koke

bug 2019-04-04 19_34_43

koke avatar Apr 04 '19 17:04 koke

Confirmed as well on iOS. The text isn't deleted every time, sometimes I see the cursor thing only

koke avatar Apr 04 '19 17:04 koke

While investigating this problem found out that we're only storing the content of the block in history, then when the user taps on the undo/redo buttons the content of the block is changed but the caret position is not updated. The web side is working on adding this info in history, so let's wait until the GB side PRs are merged and ready, since there are many problems to tackle about the caret position and restoring it. Ref: https://github.com/wordpress-mobile/gutenberg-mobile/pull/884#issuecomment-484125940

daniloercoli avatar Apr 18 '19 08:04 daniloercoli

I just tested this again on iOS, and it looks there are sync issues between the selection/move of the cursor and the writing of the text. Sometimes when pressing undo the character inserted is undo and then selection/move other times is the other way around.

2020-05-01 15-02-00 2020-05-01 15_05_57

SergioEstevao avatar May 01 '20 14:05 SergioEstevao

This may not be directly related since I'm only seeing this on Android, but I see that an extra undo point to move the cursor is getting created on Android when adding words to a paragraph block.

Steps to Reproduce

  1. Open a new post
  2. Add two words to the post by swiping
  3. Tap undo and observe the second word only is removed (the first word remains)
  4. Tap undo a second time and observe the cursor is moved to the beginning of the paragraph block, but the word is not removed.
  5. Tap undo a third time and observe the remaining word is removed.

android_undo_weirdness_better mp4

mchowning avatar Jun 09 '20 20:06 mchowning

cursor positioning on Rich Text-based blocks after undoing is pos+1

I was able to reproduce this one on a recent version (alpha-233). Cursor moves "randomly" after the undo (sometimes one more character to the right).

maxme avatar Jul 15 '20 08:07 maxme

Moved from High prio to Medium, I wasn't able to reproduce the content loss (like in https://github.com/wordpress-mobile/gutenberg-mobile/issues/303#issuecomment-479992707)

maxme avatar Jul 15 '20 08:07 maxme

Some improvements were made to undo/redo in 15.6. See https://github.com/WordPress/gutenberg/pull/24116. Props @dratwas. 🎉

During beta testing for 15.6, I found that the cursor still moves around unexpectedly as described in this issue. I also didn't experience any content loss as maxme also mentioned above. 👍

In my case, when adding a few sentences to the beginning of a paragraph block then removing them with undo, the cursor always seemed to land one character short of where I think it should be landing (pos-1 instead of pos+1).

notice-where-the-cursor-lands-on-undo-wpios-15 6 0 1

Tested with WPiOS 15.6.0.1 TestFlight beta on iPhone 11 iOS 13.6.1.

When I tried the original steps for this issue, I found that the cursor landed at the end of the most recently added text when I added a space to the middle of a word then tapped undo.

gutenberg-mobile-303-add-remove-space-from-word-wpios-15 6 0 1

Tested with WPiOS 15.6.0.1 TestFlight beta on iPhone 11 iOS 13.6.1.

When I tried the steps from mchowning's comment, I found that it only took two undos to remove the two words added but the cursor jumps to the beginning of the text after the first undo which is unexpected.

gutenberg-mobile-303-add-two-words-then-undo-twice-wpios-15 6 0 1

Tested with WPiOS 15.6.0.1 TestFlight beta on iPhone 11 iOS 13.6.1.

designsimply avatar Aug 27 '20 21:08 designsimply

This ticket is not worked on at the moment so, I'll clear the assignee field to denote so.

hypest avatar Oct 22 '20 10:10 hypest

This is still reproducible but there's a debounce of 1 second. The steps are:

  1. Type letter "A"
  2. Wait 1 second
  3. Type letter "b"
  4. Wait 1 second
  5. Press undo
  6. The cursor goes to the position before the letter "A" but it should be after it.

Result

Tested with GutenbergDemo app 1.40.0 iPhone 11 simulator on iOS 14

Action

action

State Diff

diff

The RESET_SELECTION action seemed to be getting called with wrong offset value, but didn't have enough time to trace the root cause.

ceyhun avatar Nov 10 '20 11:11 ceyhun

FYI: Still an issue as of 1.57.0. Tested on a physical Pixel 4 running Android 11 w/ Gboard:

https://user-images.githubusercontent.com/5810477/125358639-28ac0280-e337-11eb-8c58-99f634d7d72c.mp4

AmandaRiu avatar Jul 12 '21 21:07 AmandaRiu

Noting that this can still be replicated, most recently tested on an iPhone XR with the pr18445-7dc96cb build.

SiobhyB avatar Apr 26 '22 10:04 SiobhyB