fix: unescape Gutenberg title value #1497
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
issue #1495
Get ready for some WordPress nonsense.
The Gutenberg editor has two modes: visual and code. We access the title data with its official API:
select('core/editor').getEditedPostAttribute('title')
.Scenario: User types
Foo & Bar
into the title field.In the code mode (the one probably barely anyone uses), the behavior is as expected. The value is
Foo & Bar
.In the visual mode, the value is ... 🥁 ... escaped!
Foo & Bar
!So the user types the same thing, but the end value in the JS API is different, depending on a view mode? Makes total sense! Anyway, we use
htmlEntities.decodeEntities
then when accessing the title value to ensure the title is always unescaped. Looks fine in the frontend now (and that's the current state of this PR).All good now? God no! Because WordPress actually persists the escaped title data in the database! So the title data in the feed is broken. Needs some more work and testing of various settings to ensure the value in the feed is always correct. And maybe check if only
&
is affected or also emojis etc.