-
Notifications
You must be signed in to change notification settings - Fork 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
FSE: Fix description block jumping around in the editor #35065
Conversation
- This fixes an issue where the text would jump around when selecting the description textbox in the post editor. - This will also give us more flexibility in the future to expand what users can do with this block.
This PR does not affect the size of JS and CSS bundles shipped to the user's browser. Generated by performance advisor bot at iscalypsofastyet.com. |
className={ className } | ||
value={ option } | ||
tagName="p" | ||
formattingControls={ [] } |
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.
Ah interesting, does this prevent keyboard commands for applying things like bold styling?
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.
Looks like that's not the case testing on wpcom. Let's stick with the PlainText component and update editor styling to better match the block selected state (with selection) vs preview state. Let us know if this is tricky to find, we'd be happy to help.
The description is going to be plain text, so any html content will be escaped like:
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.
So formattingControls={ [] }
is supposed to remove formatting controls from the RichText block - is that a bug where it doesn't work on wpcom? I used this specifically to get rid of the escaped content issue :(
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'm testing on gutenberg master so maybe it's a new feature?
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'm testing on gutenberg master so maybe it's a new feature?
Can maybe verify by checking out back to v6.1.1 though I wouldn't assume so?
Curious what the original use case for that is, re-size via dragging the text area? I wonder if we can pass a setting for single line support only to the component? This would also fix #34419 |
@gwwar I did initially try to fix this with just theme styling. The jumping around after initial selection is caused by an extra bit of margin that gets applied in the focused state in the modern business theme. However, there is still a non theme styling issue after that. As you can see here: #34886 (comment) the height is manually set in such a way that we can't easily override it via the theme's editor stylesheet. Thankfully, the margin issue doesn't happen when we use RichText, which is nice. :) One fix for that is to specify Per textarea settings, you can use maxRows, but that doesn't avoid newlines and such. And doesn't fix the jumping around :) Personally, I like that RichText allows us to support a lot more than PlainText if we want to in the future (i.e. why not allow a user to bold a word in their description?) as long as we can avoid the escaping issues until we fix up everywhere that consumes it. Rich text also provides support out of the box for single line behavior. I can try to see what causes the library to give it a higher hight in the beginning though since RichText won't work for us on wpcom yet! |
I'd would expect us to support font sizes, faces, variations, and even colors in the future. Users will definitely want to change the text site, and font (beyond any global style settings we give them). |
@apeatling Should we ditch the Site Description block then and put in a paragraph block? |
It's not that RichText can't work, we also need to account for our own customizations, like adding underline/justify. https://github.com/Automattic/wp-calypso/tree/master/apps/wpcom-block-editor/src/common If we're okay with the RichText component, I'm sure we can make it work with enough debugging. |
Yeah, I wonder if we could pass through the prop to disable customizations for now. I didn't realize we had a wpcom override 🙃 |
I don't want to hold up anything here because of possible things we might do in the future. So I am fine with doing whatever is easiest to fix this right now. |
If you have time @Copons, appreciated if you can help troubleshoot. @noahtallen see #28696 for context on why we have an override for RichText. |
Darn. I can't figure out why it ignores the prop on wpcom. We aren't modifying rich text, we're just adding more format options. I was really hoping we could stick with this since it seems like we'll have to modify all of the theme styles too. |
This appears to be caused by a bottom margin added by the theme: See what happens when I toggle it in the dev tools: |
@Copons you're definitely right, that's the first thing I tried to fix ;) Unfortunately, even when I fix the margin issue, there is another jump which only happens when clicking into the box for the first time. Check this out: |
Ha! Shame on me for scanning the comments a bit too quickly! 🤦♂ What about adjusting both the margin the line height? On the other hand, with this I can't see any jumps anymore (but my eyes are tired, so I might be wrong 🤔): .site-description,
.wp-block-a8c-site-description,
.wp-block-a8c-site-description:focus {
color: $color__text-main;
font-size: $font__size-xs;
font-weight: 300;
- margin: 0 0 calc(0.5 * #{$size__spacing-unit});
+ line-height: 28px;
order: 1;
} |
Wow, nice call! Setting the line height makes the initial jump go away too. One theme fix coming up :) |
Since the issue is in theme styling, I'll close this PR and open a theme PR. |
This fixes an issue where the text would jump around when selecting the description textbox in the post editor.
No Jumping:
This will also give us more flexibility in the future to expand what users can do with this block. For example, we can disable multiline input and allow people to do bold/italics and stuff like that. For now, I have not included that support since it will mean changing the rendering logic in php, which is beyond the scope of this PR.
Changes proposed in this Pull Request
Testing instructions
Fixes #34886