Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RichText: empty anchor is removed (also in classic editor) #13331

Open
greatislander opened this issue Jan 15, 2019 · 2 comments
Open

RichText: empty anchor is removed (also in classic editor) #13331

greatislander opened this issue Jan 15, 2019 · 2 comments
Labels
[Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Type] Bug An existing feature does not function as intended

Comments

@greatislander
Copy link
Contributor

Describe the bug
When editing a paragraph containing an anchor (e.g. ) in Firefox (64.0.2, macOS 10.14.2), pressing the delete key to delete any text in the paragraph removes the anchor, regardless of the position of the cursor in relation to the anchor within the paragraph. This affects both classic blocks and paragraph blocks.

To Reproduce
Steps to reproduce the behavior:

  1. In HTML mode, add an anchor to a paragraph in a classic block or paragraph block.
  2. Switch to visual mode.
  3. Position the cursor anywhere within the paragraph, and press the delete key to delete text.
  4. Observe that the anchor disappears.

Expected behavior
The anchor should be unaffected unless the cursor directly follows the anchor icon when the delete key is pressed.

Screenshots
https://cl.ly/24307cf3c26c

Desktop (please complete the following information):

  • OS: macOS 10.14.2
  • Browser: Firefox
  • Version: 64.0.2

Additional context

  • This issue affects WordPress 5.0.3.
  • The "Undo" button in the toolbar of the classic block can be used to restore the anchor. However, Gutenberg's "Undo" button does not restore an anchor deleted from a paragraph block.
  • This issue also affects the Classic Editor (see: https://core.trac.wordpress.org/ticket/45992).
@designsimply designsimply added [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... Needs Testing Needs further testing to be confirmed. labels Jan 15, 2019
@ellatrix
Copy link
Member

This works for me if the anchor has content. What's a good use case of adding on empty anchor?

@ellatrix ellatrix changed the title Pressing delete key within classic or paragraph block containing an anchor deletes the anchor (Firefox) RichText: empty anchor is removed (also in classic editor) Mar 15, 2019
@noisysocks noisysocks added [Type] Bug An existing feature does not function as intended and removed Needs Testing Needs further testing to be confirmed. labels Feb 6, 2020
@noisysocks
Copy link
Member

noisysocks commented Feb 6, 2020

Confirmed that this happens in latest development version of Gutenberg, so removing Needs Testing.

I'm not 100% sure that it's a bug, though, as it's generally not expected that one can insert arbitrary HTML (including an empty <a> tag) into any block. The only use-case for an empty anchor that I can think of is inserting a page jump e.g. <a name="you-can-link-to-here"></a>. Using an HTML block is workaround for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

4 participants