-
-
Notifications
You must be signed in to change notification settings - Fork 3.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
[API] Single Select Component #140
Comments
My biggest concern with the Select component is whether it will be easy to test in unit tests with Jest and End to End tests with Cypress. Here's an example: /**
* Create a Project
*/
cy.getByTestId("button-add-project").click();
cy.getByTestId("input-project-title").type("E2E Test Project");
cy.getByTestId("button-wizard-next").click();
cy.getByTestId("input-project-description").type(
"E2E Test Project description"
);
cy.getByTestId("button-wizard-next").click();
cy.getByTestId("select-agency").click();
// Choose 'Testing Agency'
cy.get("#react-select-2-option-4").click();
/**
* Clicking multiple times makes this test more resilient
* @see https://github.com/cypress-io/cypress/issues/1486#issuecomment-450151465
* @see https://github.com/cypress-io/cypress/pull/2982
*/
cy.getByTestId("select-client")
.click()
.click()
.click();
// Choose 'Testing Client'
cy.get("#react-select-3-option-0").click();
cy.getByTestId("button-wizard-next").click();
cy.getByTestId("select-template")
.eq(0)
.click();
cy.getByTestId("button-wizard-complete").click(); I'm hoping your approach of putting accessibility first (which is really great!) will mean this won't be a concern! |
Did we get anywhere with this component @segunadebayo? Did you find any third party components that might fit in with Chakra? I need to implement a single select in my current project so I'm just about to start researching. If I find anything good, I could post it here if that would help? |
Hi @aaronmcadam, I've built a custom select already, it's in the However, if you find an implementation other than |
Hi @segunadebayo, thanks for getting back to me. I ended up using an old component we had that uses That's great news that you've got something working in the TypeScript branch. I'd like to give you a hand with some of the work when I get a chance. |
I did have a look at Reach UI's Combobox, and while it's a great example of how to build an accessible and testable component, it didn't fit my simple needs and the needs of this RFC. |
I'm curious @aaronmcadam. What do you mean by "simple needs"? Just to be sure what I've worked on covers this 😄 |
The same needs as mentioned above: just a select component that allows you choose from a list of options. The combobox is more of an extended text input, in that you can choose an option or type your own value. Does that make sense? |
@segunadebayo I do need to be able to have a more complex option than just text though. In my case I need to have an icon beside some text. I'm AFK at the moment but I'll attach a screenshot tomorrow |
@aaronmcadam. I've got you covered then. |
@segunadebayo For clarity, here's my use case: |
@aaronmcadam There won't be an input to search options in the |
Hello! Are there any updates on this? It would be really cool to have this in this awesome lib! Cheers! |
Hi @Martinnord, The select component is in progress, you can track it in the |
@segunadebayo Cool! Will keep an eye on that branch! |
@segunadebayo I want to help you this component. Can you guide me?. I am beginner in open source. |
@Enigma10, Thanks for offering to help. For now, we've de-scoped the Select component to help us focus on the next major release. Once we get back to it, I'll drop a comment here so I can guide you. Cheers. |
Hello there, @segunadebayo We decided to use your Chakra as the initial DS, congratulations on your project, it's great. 👏 So, we missed the searchable select and I read the issue here and we want to know if it has ETA to launch? We can access the component to see if we can help? |
@segunadebayo |
Hi! I'm checking in to see if there's a plan to implement a searchable select? styling with react-select is 👎🏾 |
@TaylorFacen You should check out my wrapper for react-select. I spent a decent amount of time replacing the react-select styles with the chakra ones, in some cases just replacing the components entirely.
EDIT I've noticed that this has gotten a positive reception so I figured I'd post an update. The wrapper I posted is now updated to more accurately work with the react-select controls, and also now has a size prop! it can accept EDIT 2 I made it into an NPM package! https://www.npmjs.com/package/chakra-react-select |
Nice job! I'm kinda new to software development and a documentation on this would be nice. Do you have any? If not, could help me with something? Thanks in advance |
@onurbamaro I don't have any documentation but it should take the same props as the original package. As long as you have If you have a specific question, feel free to ask! |
Oh, now I get it. That's what I was looking for! Thank you and nice job once again, this is going to help a lot! |
@onurbamaro You're welcome! |
@segunadebayo Has there been any consideration into expanding the select component to include search of extending it in a new component? @csandman did great work on his own solution, but having something directly from Chakra without relying on React-Select that is also in the Chakra TS ecosystem would be nice. |
@tannerbaum I definitely agree that it would be great to have a combobox type component native to the Chakra lib, the component I made was only ever supposed to be a holdover until something like that exists |
@tannerbaum There's been some experiments using Downshift on Chakra UI Pro. I've not had a chance to play with the component yet, though. But if the component is stable enough, it may make its way into the library. |
There's also a project that's focused on autocomplete features that uses the Downshift library's ComboBox: |
For anyone that has had any interest in my wrapper for react-select, I made it into an NPM package. You can find it here: https://www.npmjs.com/package/chakra-react-select |
@csandman My team and I are using your wrapper in our project. Any hints on testing it with jest/enzyme? It's actually a component with parts of your code from codesandbox |
@emvictor sorry, can't really help you there, I've never done a lot of testing. I've only used jest in one project and I never got that far with it. |
There have been some major improvements in version 2 and version 3 of my |
Following our discussion in Issue #38. I thought to put down my thoughts about
the Single Select component and the API I have in mind.
NB: I know there are other use cases, like Multiple Selects and ComboBox, but
we're keeping it simple for now. We'll start with a Single Select Component
The Goal:
Create a select component that works just like the native select and accessible,
composable and super easy to style.
The single select will follow WAI-ARIA specs for the list box pattern. These are the
key resources we need to create this Select
Key Features:
with a name that starts with the string of characters typed.
disabled should be skipped in the navigation.
via keyboard or typeahead, any option is focused that isn't (fully) visible
should be scrolled into view. Perhaps
scroll-into-view-if-needed
might help.autoSelect
is true, highlighting an option must also select that optionautoSelect
is false, a highlighted option must be manually selectedusing the SPACEBAR or ENTER key.
improve render performance by using
react-virtualized
Import
Component Parts:
button
but can also use a render prop in case user needs full control of the rendering.Popper
component.It can also use a render prop incase user needs access to the interal state.
navigation and typeahead functions.
to the
<optgroup>
in the native browser select.Usage
The Select should also be able to render an option group. If passed
isDisabled
, the options should also be disabled.Props
Select Props (Provides Context)
true
, the select should be open initially.true
, the select should be open in controlled mode.initially.
true
, the option will be selected as you navigate throughthem.
true
, the select menu will close on blur or outside clicktrue
, the select menu will close when you pressescape
true
, the select menu will close when you select anoption.
true
the select control will be disabledtrue
, the select control will havearia-invalid
set to truetrue
, the select will be in read-only modeprovides:
SelectOptionGroup Props (composes Box)
true
, all the SelectOption that it wraps will be disabledSelectOption Props (composes PseudoBox)
The text was updated successfully, but these errors were encountered: