-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Improved rich text placeholder #16733
Conversation
margin-top: 0; | ||
|
||
& > p { | ||
margin-top: 0; |
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.
This is no longer necessary, since we're not duplicating the whole rich text element.
c8334ee
to
9254300
Compare
4ae0da8
to
2410275
Compare
@jasmussen @kjellr Would love your review on this as you have worked a lot with themes before. This change should make placeholder more invisible when developing themes, so themes should never have to take them into account. |
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.
From a theme perspective, this seems great. Definitely a positive move. ⭐️
I tested in a handful of existing themes, and saw no negative effects. The only placeholder that does still seem to perform oddly is the very first paragraph placeholder for an empty doc — this one is still rendered as a textarea, so it doesn't always inherit the correct text styles. This was existing behavior though, so it can be looked into separately.
2410275
to
69cb29d
Compare
Sounds like we should use RichText there instead. :) Let's iterate if any placeholders turn out to be a bit off, also for the core blocks. If we end up needing placeholders on focus again, we can use CSS for those specific blocks, or reintroduce the prop to enable this rule. &.is-selected [data-rich-text-placeholder]::after {
display: inline;
} |
I definitely want placeholder on focus back. It's standard behavior as agreed here #806. When I insert a block and it autofocuses the first Rich Text input then I don't see the placeholder at all. There's no blinking cursor either for some blocks, the At least a prop for it would be welcome. Edit: wait, there was a prop |
@ktmn You might want to have a look at e.g. the button block, which is also collapsed if there is no content. I think the key is to set |
That does add some width, but it's not necessary with: .rich-text.is-selected [data-rich-text-placeholder]::after {
display: inline-block;
} But with that I cannot click on the
So I feel like there needs to be some JS click delegation going on that I can't solve with CSS. Can you solve it? And then bring back |
I'd like to ask the team where the removal of I can't find anything related in the changelogs or in the deprecations. This prop removal is definitely breaking the interaction on some custom plugins blocks. This kind of changes may appear safe in the context of Gutenberg but they're definitely breaking changes for plugins. They need to be documented and communicated well in advance of a WordPress release. Not to mention the time necessary to debug issues produced by undocumented, breaking, changes is considerably high. I'd also like to point out, as @ktmn mentioned, that the editable within custom blocks that use See in the screenshots below: notice the mouse pointer indicates the "clickability" only on the right part of the editable, and see the non-clickable |
Description
This small PR improves the currently clunky placeholder text for rich text instances.
The way placeholders are currently implemented is by "shadowing" the whole rich text element.
:before
or:after
). See the double line?p
handling).When placeholders were first implemented, we used
:before
, but we cannot do that as themes may use pseudo elements for styling.What I propose here is to insert a placeholder
span
element whenever then content is empty. This way the styling is always correct. It's as if the text is just there. This implementation requires less code, and it feel a lot "cleaner".How has this been tested?
Screenshots
Types of changes
Checklist: