Make WordPress Core

Opened 9 months ago

Last modified 9 days 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:


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 (1)

tweet auto embed.gif (389.7 KB) - added by afercia 12 days ago.

Download all attachments as: .zip

Change History (8)

#1 @azaozz
12 days 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
12 days 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
12 days ago

Update: tested also on Windows and can still reproduce.

#4 @azaozz
12 days 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
9 days 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
9 days 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
9 days ago

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

Note: See TracTickets for help on using tickets.