WordPress.org

Make WordPress Core

Opened 10 months ago

Last modified 4 weeks ago

#45307 new defect (bug)

Can't undo auto-embeds

Reported by: afercia Owned by:
Milestone: 5.3 Priority: normal
Severity: normal Version: 4.8
Component: TinyMCE Keywords:
Focuses: Cc:

Description

Seems that starting from WordPress 4.8 the "Undo" in TinyMCE is unable to undo an auto-embed.

I've tested it first on WordPress 4.7:

  • create a new post
  • write something
  • add an embed URL in its own line, tried with:
    • a YouTube embed
    • a WordPress embed
  • once the auto-embed happens, clicking the Undo button or pressing Cmd / Ctrl + Z removes the auto-embed

Then I've tested the same steps in WordPress 4.8:

  • clicking the Undo button or pressing Cmd / Ctrl + Z removes the embed but it gets immediately re-embedded
  • clicking Undo multiple times enters in an Undo / auto-embed loop

Not sure anything has changed in the auto-embeds between WordPress 4.7 and 4.8, seems to me more related to TinyMCE. For what is worth, it happens also in Gutenberg.

Attachments (3)

tweet auto embed.gif (389.7 KB) - added by afercia 2 months ago.
ff1.gif (660.6 KB) - added by afercia 4 weeks ago.
ff2.gif (770.1 KB) - added by afercia 4 weeks ago.

Download all attachments as: .zip

Change History (12)

#1 @azaozz
2 months ago

Undo seems to be working properly (again) in WP 5.2. Tested in Firefox and Chromium on Win10. @afercia could you confirm please :)

#2 @afercia
2 months ago

@azaozz I can still reproduce on trunk and 5.2.2, macOS, all browsers :) See attached animated GIF where I'm first using Cmd + Z and then the Undo button. Happens with all embed types, also with Gutenberg. Will test on Windows 10 later.

#3 @afercia
2 months ago

Update: tested also on Windows and can still reproduce.

#4 @azaozz
2 months ago

  • Milestone changed from Awaiting Review to Future Release

Ah, I see, the wpview has to be the first node in the editor. Then I can reproduce it too, every time. If it is not the first node, undo works as expected until you switch to the Text tab. Then it may start failing too (seems related to where the cursor is when switching).

Trying to figure out what's going on :)

#5 @azaozz
2 months ago

  • Milestone changed from Future Release to 5.3

Think I found it. The way undo levels are stored in the editor has changed quite a bit so we are processing some undo levels but not others.

Patch coming up.

#6 @azaozz
2 months ago

In 45631:

TinyMCE: fix adding of too many undo levels for wpviews. The HTML changes several times when a wpview is added. We only want one undo level. Also fixes cases when the cursor is next to an embeddable URL in the Text tab and the user switches to the Visual tab.

See #45307.

#7 @azaozz
2 months ago

Leaving open for now in case there are any (edge case) regressions.

#8 @desrosj
4 weeks ago

@afercia are you able to confirm that [45631] fixes the issue for you?

#9 @afercia
4 weeks ago

I'm not sure it's fully fixed.

A single auto-embed followed by an Undo seems to work. However, then going back/forth through Undo/Redo multiple times, things get a bit weird. Seems to me at any unrelated Undo (e.g. removal of text), the embed auto-embeds again thus creating messing up the Undo/Redo history?

See GIf below, latest Firefox on macOS (similar results with Chrome).

@afercia
4 weeks ago

@afercia
4 weeks ago

Note: See TracTickets for help on using tickets.