Uh oh!
There was an error while loading. Please reload this page.
Select input component - #1736
Conversation
🦋 Changeset detectedLatest commit: fa45ce6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
size-limit report 📦
|
| @@ -0,0 +1,100 @@ | |||
| --- | |||
| title: Select | |||
There was a problem hiding this comment.
I'm thinking maybe "SelectInput" is a better name. I'd love to hear what other reviewers think.
There was a problem hiding this comment.
Yep! I think so too. It kinda cements it as a Form component and not any fancy menu/overlay interface
There was a problem hiding this comment.
We only recently decided to avoid using *Input suffix on form components, so I'm in favour of keeping it as Select here. Reason: a) To match the underlying HTML and b) be consistent with other form components like Radio, Checkbox.
pksjce
commented
Dec 15, 2021
There seems to be a clash here 😅 I'll close mine, as I'm yet to implement optgroups and review yours. |
| export default Object.assign(Select, { | ||
| Option, | ||
| Group |
There was a problem hiding this comment.
➕ . Can we call it OptionGroup to avoid the abbreviation?
There was a problem hiding this comment.
I think if we're going to call the parent component Select, OptGroup might make more sense because it's closer to the HTML tag name: <optgroup>
| {...rest} | ||
| > | ||
| {placeholder ? ( | ||
| <option value="" disabled={required} selected hidden={required}> |
There was a problem hiding this comment.
I think we need a storybook to show what this looks like?
There was a problem hiding this comment.
You can see it by using the Controls. Do you think we need something more prominent?
| type: 'boolean' | ||
| } | ||
| }, | ||
| contrast: { |
There was a problem hiding this comment.
This shouldn't be relevant for this component
There was a problem hiding this comment.
Ok. I can remove it and we can always add it later if we decide we want parity with TextInput
| } | ||
| }, | ||
| variant: { | ||
| name: 'Variant', |
There was a problem hiding this comment.
Yes, absolutely. I was waiting for #1661 to merge which deprecates variant and adds size.
pksjce
commented
Dec 15, 2021
| storybook: '/react/storybook?path=/story/forms-select--default' | ||
| --- | ||
| import {ComponentChecklist} from '../src/component-checklist' |
There was a problem hiding this comment.
Don't think we need to import this anymore as it's global
There was a problem hiding this comment.
That's what I thought too, but if I don't import it, it doesn't render.
There was a problem hiding this comment.
Could your /docs node_modules need updating?
| const StyledSelect = styled(TextInputWrapper)<SelectProps>` | ||
| appearance: none; | ||
| background-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0iIzU4NjA2OSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNNC40MjcgOS40MjdsMy4zOTYgMy4zOTZhLjI1MS4yNTEgMCAwMC4zNTQgMGwzLjM5Ni0zLjM5NkEuMjUuMjUgMCAwMDExLjM5NiA5SDQuNjA0YS4yNS4yNSAwIDAwLS4xNzcuNDI3ek00LjQyMyA2LjQ3TDcuODIgMy4wNzJhLjI1LjI1IDAgMDEuMzU0IDBMMTEuNTcgNi40N2EuMjUuMjUgMCAwMS0uMTc3LjQyN0g0LjZhLjI1LjI1IDAgMDEtLjE3Ny0uNDI3eiIgLz48L3N2Zz4=); |
There was a problem hiding this comment.
Is there a way we can show the icon without using a base64 uri? It's quite expensive on the runtime and AFAIK a new pattern to PRC that could set a slippery precedent. Also, this image in its current form seems incompatible with other colour modes. Worth looking at pulling this in as a composable icon instead?
There was a problem hiding this comment.
Those are both great points. I'll investigate alternatives.
| background-size: 16px; | ||
| padding-right: 20px; | ||
| cursor: pointer; | ||
There was a problem hiding this comment.
worth setting the background-color here too?
There was a problem hiding this comment.
That should be handled in the TextInputWrapper component.
Uh oh!
There was an error while loading. Please reload this page.
mperrotti
commented
Dec 15, 2021
That will be handled by the InputFieldComponent added in #1611
That's no good. I'll take a look. |
Co-authored-by: Rez <rezrah@github.com>
| expect.extend(toHaveNoViolations) | ||
| describe('Radio', () => { |
| const select = getByLabelText('Choice') | ||
| expect(select.getAttribute('aria-disabled')).toBeTruthy() |
There was a problem hiding this comment.
❤️ . Personal preference, but@testing-library/jest-dom has some nice, more easily-readable matchers for this type of test. E.g.
| expect(select.getAttribute('aria-disabled')).toBeTruthy() | |
| expect(select).toHaveAttribute('aria-disabled') |
rezrah
left a comment
There was a problem hiding this comment.
Looks good to go, nice one @mperrotti. Just a heads up, this won't appear on the primer.style/status page until you add comonentId to the front-matter. Might be worth sticking that into this PR or in a follow-up.



Adds a styled native
<select>input componentCloseshttps://github.com/github/primer/issues/540
Screenshots
Kapture.2021-12-14.at.15.24.42.mp4
Merge checklist
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.