Skip to content
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

feat(SelectControl): add children prop #29540

Open
wants to merge 1 commit into
base: trunk
from

Conversation

@frosso
Copy link

@frosso frosso commented Mar 3, 2021

Description

It looks like the select-control component accepts an options 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 current options prop.

I understand that options is provided as an abstraction, but I think that rather than changing the options prop, we can leverage the native children 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 the children 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 of children?

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:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.
@github-actions
Copy link

@github-actions github-actions bot commented Mar 3, 2021

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @frosso! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@frosso frosso marked this pull request as ready for review Mar 3, 2021
@frosso frosso requested review from ajitbohra and chrisvanpatten as code owners Mar 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant