-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Post editor: Fix "typewriter" spacing style application #65885
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: -57 B (0%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
There will be no visible change in either the iframe or non-iframe editor and the padding appender will continue to work as before.
}; | ||
}, [] ); | ||
|
||
const addedStyles = additionalStyles.join( '\n' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Currently there is only one style for the padding appender, so no line break will occur, but is the line break itself even necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it’s not necessary. Passing something as a separator is required to avoid the default comma. I suppose I opted for the line break as a formatting nicety despite the fact that it’d be a rare case that anyone is actually looking at the concatenated styles (and that as of yet there’s not more than one style so it’s moot for now). Here’s an example of what it looks like inspecting the element if there were more than one style.
I don’t mind making it an empty string or space if you’d opine it should be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any strong opinions about it, so I think it's fine to merge it as is 👍
I’ve changed the type label to "Bug" because I realized that in trunk the spacing is being applied in a couple contexts it’s not intended to. See the updated description for details and a screen recording. The bug could be fixed more minimally (it’s due to the lack of two dependencies in the memo hook within |
What?
Fixes a bug where the "typewriter" space below the post content is showing up when not intended:
Also this makes
usePaddingAppender
contain its concerns and support disabling it. Follows up on #64992.Why?
To fix a bug and improve code quality.
Currently, the hook is always active in the Post editor but doesn’t have an effect in some contexts (e.g. template editing, or focused editing of template parts or patterns). It returns early in those contexts by actively testing whether its associated styling is applied in the document. Such testing is potentially brittle and unnecessary because the same conditions that omit the styling can be used to inactivate the hook.
Besides that its associated styling and the conditions for applying it are in a separate hook that ideally doesn’t own those concerns.
How?
usePaddingAppender
is enableduseEditorStyles
hook and uses them to control whether theusePaddingAppender
is enabledusePaddingAppender
own and return its stylesuseEditorStyles
accept additional styles so it can generically handle the style fromusePaddingAppender
Testing Instructions
Screen recording
This shows how on trunk the space gets added below the template when the template is set to show.
typewriter-space-after-template.mp4