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 | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | TinyMCE | Keywords: | |
Focuses: | ui | Cc: |
Description
Steps to Reproduce
- 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.
- Place your cursor within the link.
- 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
@
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
#2
@
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".
#4
@
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.
I just realized that this also affects the unlink button in the main tinyMCE toolbar.