-
Notifications
You must be signed in to change notification settings - Fork 932
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
Example, and question about api #94
Comments
Oh I wanted to add: I only made a searchTemplate entry point so that the search could apply to whatever the enduser configures. For instance maybe you want to search 'names and emails' or 'just names' - you can override the search string. I feel like for this example it might be more practical to search only titles, but I wanted to demonstrate that one could override that property. Another (more real-world) example might be an object model where the firstname and last name are seperate properties, but you want a search box where users appear to be searching const people = [
{ firstname: 'Jane', lastname: 'Doe', age: 90},
{ firstname: 'Jonny', lastname: 'Smith', age: 9},
{ firstname: 'Ghengis', lastname: 'Khan', age: 9000},
] So you're binding the combobox to a list of Similarly, the ability to override the list Item Template. Seemed sensible to have a default, and then the ability to provide something 'fancier' depending on how you might visualize the data. That said, I know this is a pretty bread and butter combobox, I'd like to experiment with some nontraditional interfaces (maybe you filter a list of tiles, etc) but I'd like to do this after I get some feedback on the api surface, and the 'downshift' way you envision handling clear selections. If I were to critique my own demo: Right now I have one part that feels a bit 'janky' and it has to do with dealing with the stringification of the selected Item. I wanted to make it so that selecting an item properly templates the text you see in the input, but In order to do that, I needed to make sure the user wan't stringfying an object (hence the [Object object] string check). This works because the moment you start typing, or deleting, we make the input based on the inputValue and not the templated selectedValue. Overall I love the direction this component has taken to decouple ui and the 'searchy bits'. The design decision to forgo ui decisions and stick to the state management and the functions is A+. I've written 3 comboboxes in my career, 1 in jQuery UI ( I'm old :) ), 1 in angular and one other in React ( around 2014 ). Each of those took a long time (many days) to complete, but I had this example up-and-going in like a few hours. I'm super happy with downshift, and I think others will be too. |
Hello, +1 for Also, could we reduce the API by removing |
@the-simian, I think that what you're talking about is properly filtering and sorting your items. That's out of scope of this project, however you really should look at Good luck! |
Also, I'm so pleased that you're enjoying this module 😄 |
I'm pretty sure that the latest version should clear up a lot of confusion. |
@kentcdodds , Hi, I think we might be talking past each other, the problem is that clearSelection does not currently also clear the input as well, and results in If you look at my example I commented where I'm having to 'guard' against the object stringification that is uncleared. I was unclear if this was what was intended, or a regression. (The api has changed terms in the last couple days). Really 'clearing' is the only part of the demo I am not sure I'm doing correctly. I am currently filtering with the native filter method now, so I'm not asking about how to do that, currently. |
thanks for clearing up on my other api questions - I'm looking over the diff to remove any stale references in my demo |
Yes! You're right! It did that, but I just fixed it 😄 Try Thank you so much! |
Will do, and thank you @kentcdodds :) |
downshift
version: Betanode
version: 8.2.1npm
(oryarn
) version: yarn 0.27.5Relevant code or config
Hello! I've been fleshing out a super basic example that is for binding a list of object in the context of Material UI, that' I'd love to submit to the #1 when I've polished more.
see live example: https://codesandbox.io/s/QMGq4kAY
I had a question about the api, and its because I worked last night and also today, and I think I observed some of the values change. So quick questions:
value
orinputValue
selectedItem
orselectedValue
selectedItem
the functionclearSelection
seemed to clear both the input and the selected Item (which was convenient), and the new one only clears the selectedselectedValue
/selectedItem
, is there another way to clear the input now? I get stuck with[object object
Thank ya'll for the awesome plugin, so far I really like it!!
The text was updated successfully, but these errors were encountered: