-
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
Typography Panel: Make letter spacing jsDoc and prop use consistent #36367
Conversation
Size Change: +6 B (0%) Total Size: 1.09 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.
Thank you so much for taking action on my feedback!
* @param {Object} props Component props. | ||
* @param {string} props.value Currently selected letter-spacing. | ||
* @param {Function} props.onChange Handles change in letter-spacing selection. | ||
* @param {string|number|null} props.__unstableInputWidth Input width to pass through to inner UnitControl. |
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.
While null
is going to work at runtime (because of this check), it isn't really compatible with the type used in InputControl
:
Ideally, we should change this to
* @param {string|number|null} props.__unstableInputWidth Input width to pass through to inner UnitControl. | |
* @param {import('react').CSSProperties['width'] | } props.__unstableInputWidth Input width to pass through to inner UnitControl. Should be a valid CSS width value. |
but I'm not sure it's actually going to work (it may require the JSDoc comment to be wrapped in
/* eslint-disable jsdoc/valid-types */
[...]
/* eslint-enable jsdoc/valid-types */
A simpler version could be to:
* @param {string|number|null} props.__unstableInputWidth Input width to pass through to inner UnitControl. | |
* @param {string|number|undefined} props.__unstableInputWidth Input width to pass through to inner UnitControl. Should be a valid CSS width value. |
and maybe pass either '100%'
or ''
instead of null
?
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 simpler approach looks good to me. The jsdoc is clear, no exceptions to linting rules, and the switch to use 100%
is explicit. Hard to misinterpret that 🙂
Thanks!
Let me know if you'd still prefer the jsdoc to import the CSS width property type.
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.
Thank you for working on this — the current, simpler approach LGTM 🚀
Could you just add a small CHANGELOG entry under Experimental
before merging?
ed6eaf8
to
85635f5
Compare
Description
This PR addresses concerns raised in #35911 (review) where the default
__unstableWidth
value for the letter spacing control is overridden so that100%
width can be restored when in the context of the TypographyToolsPanel
.How has this been tested?
100%
width60px
widthScreenshots
Types of changes
Enhancement.
Checklist:
*.native.js
files for terms that need renaming or removal).