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

Fix empty heading anchor id leaving an empty id attribute on heading html tags #11900

Conversation

andrewserong
Copy link
Contributor

Description

Resolves: #11663

This PR resolves the bug where an empty anchor id on a heading block would result in a stray empty id attribute on the heading html tag. This solution updates the editor anchor hook to check that the anchor id attribute is not an empty string before saving it as additional props. Also adds a test to cover this behaviour.

How has this been tested?

  • Added additional unit test for the anchor addSaveProps method to check that an empty string passed in to extraProps does not result in an id being created.
  • Manually tested in Chrome 70.0.3538.77 and Safari Version 12.0 (13606.2.11) on macOS High Sierra 10.13.6.

Steps to reproduce the behaviour (from issue #11663):

  • Insert a heading block and type some text
  • In the Advanced panel, set an HTML Anchor attribute
  • Empty the HTML Anchor field
  • Switch to Code Editor.

Screenshots

Types of changes

Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

…ing html tag (WordPress#11663)

This commit checks that the anchor id attribute is not an empty string before saving it as additional props. Also adds a test to cover this behaviour.
@gziolo
Copy link
Member

gziolo commented Feb 4, 2019

The same issue was fixed with a very similar change in #12728 by @saleehk. I'm closing this one as a duplicate. Thank you for your time spend on this contribution.

@gziolo gziolo closed this Feb 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deleting an HTML Anchor attribute leaves an empty HTML id attribute
2 participants