wordpress-mobile / gutenberg-mobile

Mobile version of Gutenberg - native iOS and Android
GNU General Public License v2.0
239 stars 55 forks source link

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

Open mzorz opened 5 years ago

mzorz commented 5 years ago
  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"
koke commented 5 years ago

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

koke commented 5 years ago

bug 2019-04-04 19_34_43

koke commented 5 years ago

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

daniloercoli commented 5 years ago

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

SergioEstevao commented 4 years ago

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

mchowning commented 4 years ago

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

maxme commented 4 years ago

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 commented 4 years ago

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)

designsimply commented 3 years ago

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.

hypest commented 3 years ago

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

ceyhun commented 3 years ago

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.

AmandaRiu commented 3 years ago

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

SiobhyB commented 2 years ago

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