feat(SelectControl): add children prop #29540
Open
Conversation
If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Description
It looks like the
select-control
component accepts anoptions
prop, which is just an array of options that are mapped to<option />
elements.<optgroup />
s are a native part of JSX. However, they cannot be added through the currentoptions
prop.I understand that
options
is provided as an abstraction, but I think that rather than changing theoptions
prop, we can leverage the nativechildren
prop present on all the JSX elements and obtain the same result.We could still leverage the
options
prop to add<optgroup />
elements, but where's the fun in that? It seems to me that by leveraging thechildren
prop we can have a more semantical component. And with that we can just leverage<optgroup />
s natively!I kept the
options
prop, but maybe it can deprecated in favor ofchildren
?How has this been tested?
I tested this in Storybook. I also added some unit tests for the component (there weren't any before).
Screenshots
https://d.pr/i/JvrB57
Types of changes
Checklist: