Make WordPress Core

Opened 9 years ago

Closed 5 years ago

#34355 closed defect (bug) (worksforme)

Editor: Cannot remove link if link text is wrapped in code tags

Reported by: jdgrimes's profile jdgrimes Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: TinyMCE Keywords:
Focuses: ui Cc:

Description

Steps to Reproduce

  1. Create a new post with this content:
    The <a href="https://developer.wordpress.org/reference/functions/add_post_meta/"><code>add_post_meta()</code></a> function.
    
  2. Place your cursor within the link.
  3. When the link toolbar appears, click the Remove button.

Expected Result

The link is removed.

Actual Result

Nothing happens.


If you remove the <code> tags, or add more text to the link and place the cursor outside the code tags, the problem goes away.

If you use a different tag, <span> for example, it works correctly.

I assume that tinyMCE is running the unlink command against the code tags instead of the a tag, and therefore it is failing.

I have tested this in trunk and in version 4.3.1.

Change History (4)

#1 @jdgrimes
9 years ago

  • Summary changed from Cannot remove link using link toolbar if link text is wrapped in code tags to Editor: Cannot remove link if link text is wrapped in code tags

I just realized that this also affects the unlink button in the main tinyMCE toolbar.

#2 @azaozz
9 years ago

  • Component changed from Editor to TinyMCE

Reproduced, also happens when several tags are wrapped in a link. This seems to be a bug in contentEditable (which executes the unlink command). Seems to happen because the selected element is not the link but (one of) the tags inside it.

Perhaps this can be fixed in TinyMCE, will report upstream. In the meantime a workaround is to select the link plus some text (or space) outside of it, and then click "Unlink".

#3 @azaozz
9 years ago

  • Milestone changed from Awaiting Review to Future Release
  • Version 4.3.1 deleted

#4 @azaozz
5 years ago

  • Resolution set to worksforme
  • Status changed from new to closed

This seems to work properly in RichText in the block editor. As it is a conenteditable behaviour that's not fixed upstream, not sure what we can do in WP about it.

The "proper way" to unlink is to select some text around the link, then it works regardless of any other elements inside the <a> tag.

Note: See TracTickets for help on using tickets.