-
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
Fix bug with getFontSizeClass crashing if passed a number #32720
Conversation
Size Change: +154 B (0%) Total Size: 1.04 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 @glendaviesnz for your work here!
Should we better convert and log to inform devs only if a number
is passed, instead of adding a comment there? font-size
hook declares the attribute as a string
so even if we fallback gracefully, I don't think it should be there for long.
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.
LGTM 🚢
I tested this along with #32722.
Prior to applying this fix, I could replicate the errors, afterwards there were none.
👋 Changes look good. I echo Nik's comment on logging to console so devs know that a number isn't the expected input for this. |
@glendaviesnz @aaronrobertshaw I'd like to prepare a 10.8.2 that includes this and #32722 as well. I know it's late for you, so I was thinking about taking over these two PRs and get them ready to the patch release. |
Should we add some unit tests to cover #32719 (and maybe some other scenarios)? |
b9bbb59
to
208e089
Compare
I'll add some... |
I'm trying to add a unit test that checks if So I've tried the following:
But apparently, it's now really throwing a console warning; instead, I'm getting the following test error:
Any idea how to fix that? 🤔 |
I'll see myself out. |
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.
The console warnings that we're getting (through deprecated()
) are
"The font size slug should be a string. is deprecated."
and
"The font size slug should not have any special character. is deprecated."
deprecated()
unconditionally appends is deprecated.
to its first arg 😕 Seems like it might not be the right tool for the job after all? Should we go with plain old console.warn()
instead?
Done that at 0b410ad |
|
||
// In the past, we used lodash's kebabCase to process slugs. | ||
// By doing so, this method also stripped special characters | ||
// such as the # in "#FFFFF". Some plugins relied on this behavior. |
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.
Looking at this again, what kind of values are we expecting here? 🤔 #FFFFFF
would be a color value -- that really doesn't make a whole lot of sense for a font size, so we might not want to support that.
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.
Happy to update the comment, but I think we still need to provide this conversion: someone may have been doing $my_font_size
.
@ockham and I looked into this and it looks like there are some cases we need to cover such as |
@nosolosw - did you want to keep this one open to circle back on this work, or will you open new PRs for the rework of this? Feel free to close it if not needed now. |
Description
With Gutenberg 10.8.1 block content fails to load in the editor if a number is passed to
getFontSizeClass
instead of a string. Previously lodash kebabCase was forgiving of this misdemeanor. This PR makes sure we have a string before running .replace to ensure that existing third party blocks that are passing a number continue to work.Fixes: #32719
To test
npm install && npm run build:plugin-zip
and upload.Switch back to editor view and make sure the content displays, and that the following error does not show in the console. (there may be some other block invalidation issues - we are working on those separately)