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

Post save is triggered without the user changing the post

Open mchowning opened this issue 4 years ago • 3 comments

Describe the bug When working on WPAndroid's post saving mechanism, I noticed that multiple saves were being triggered from gutenberg when scrolling through a post. This seemed to occur reliably with long posts (for example, the gutenberg app demo content), but would occasionally occur with shorter posts as well.

To Reproduce Steps to reproduce the behavior:

  1. Add logging to the WPAndroid app to record when Gutenberg is triggering a post save
  2. Open a large post (i.e., roughly the size of the demo app is good)
  3. Without making any changes to the post, scroll to the bottom of the post and back to the top
  4. Observe that there are multiple change events (which trigger saves).

Expected behavior When a user does not change the post, the app should not save the post.

Smartphone (please complete the following information):

  • Device: Pixel
  • OS: Android X
  • Version WPAndroid 076c52d869 (HEAD of develop on October 13, 2020)

Additional context Interestingly, another recent issue notes the opposite problem: that changes are not resulting in change events being sent, which causes the fallback save-on-exit to trigger.

This could be one of the causes of Android's performance issues with longer posts.

mchowning avatar Oct 13 '20 15:10 mchowning

👋 @designsimply , issues like this one where posts get trivially marked as modified can lead to confusing UX and lowering user's trust so, what do you think about prioritizing this rather high in the "Groundskeeping" list, considering that Matt Chowning will be on the role this week and has the best context to tackle it anyway?

hypest avatar Oct 19 '20 10:10 hypest

We have some high priority crashes to look at first, but I've added this one to the list. If we don't get to it in this round, I'll added to the next rotation as well. 👍 Thanks for asking about it!

designsimply avatar Oct 19 '20 19:10 designsimply

I tried to reproduce and indeed, one can see the post getting saved locally without any user interaction. At least in my testing, this seems to happen due to markup changes the (mobile) editor is immediately introducing to the post.

For example, the following preformatted block created from the web is getting touched when opened on mobile:

Web editor markup (Gutenberg on Calypso v12.7.1). Notice the newline before the "And more!":

<!-- wp:preformatted -->
<pre class=&quot;wp-block-preformatted&quot;>Some <em>preformatted</em> text...
And more!</pre>
<!-- /wp:preformatted -->

After being opened on the mobile block editor (WPAndroid v19.4-rc-1 (1179)). Notice the br being introduced:

<!-- wp:preformatted -->
<pre class=&quot;wp-block-preformatted&quot;>Some <em>preformatted</em> text...
<br>And more!</pre>
<!-- /wp:preformatted -->

I feel there are similar automatic modifications happening to the markup, either by block upgrades or from quirks from Aztec that trigger the autosave.

hypest avatar Mar 10 '22 12:03 hypest