-
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
CustomSelect: adjust renderSelectedValue
to fix sizing
#57865
Conversation
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.
Nice find! I believe that we can achieve the same result with fewer changes, and while keeping the defaultRenderSelectedValue
external to the component's render function.
We could remove the default assignment to the renderSelectedValue
(as you already did in this PR), and basically move the "use the default value if no value is provided" logic in the components' render function — something like
const computedRenderSelectedValue = renderSelectedValue ?? defaultRenderSelectedValue
We could then use computedRenderSelectedValue
instead of renderSelectedValue
in the JSX code.
What do you think?
Sounds great! I've implemented your solution in: dc2635e |
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 🚀
Good to merge after adding a CHANGELOG entry :)
This reverts commit 924ce00a894d820a7213412cdec9dbaa6a6cf7d0.
dc2635e
to
96f0890
Compare
Flaky tests detected in 96f0890. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7563884228
|
There are some e2e failures (Firefox getting a 500 server error) that are not related to the changes from this PR, especially because the affect code is not used nor exported by the |
What?
When creating the component, we introduced logic to have better default values for rendered select values. However, this affected the sizing styles, which relied on the boolean
hasCustomRenderProp
to check ifrenderSelectedValue
is true or not. In trunk,renderSelectedValue
will always returntrue
so the styles aren't applying as expected.Why?
To ensure the component size can be changed via the
size
prop.How?
To fix this, we can remove
defaultRenderSelectedValue
as the default value forrenderSelectedValue
and instead invoke the function only whenrenderSelectedValue
istrue
.If
renderSelectedValue
isfalse
, thecurrentValue
will be used, and if that is empty, Ariakit uses the first available value.Testing Instructions
npm run storybook:dev
CustomSelectControl V2
storysmall
are applied to the 'Default' story (they won't apply to the other stories, wherehasCustomRenderProp
istrue
.