Allow suggestions to take and return objects#4
Allow suggestions to take and return objects#4davidsharp wants to merge 5 commits intosilesky:masterfrom
Conversation
Leveraging the existing `react-native-autosuggest` code to allow typeahead for more complex objects This first pass takes objects with a `searchableID` property and takes a string format function to display it, while still accepting string terms.
This way we can show the 'term' if it's found by that, but the ID if we've found it specifically by the ID. This way we're not just displaying an ID because there is one, and it better aids messaging regarding _how_ it was found to the user.
Includes an example based on the original example
The ListView styles are all hard-coded, so this adds something slightly opinionated styles to make it a bit nicer. This should _definitely_ be offered as a prop.
|
I've also just committed 629c9e8, which highlights a candidate for another styling prop, which should probably be opened as a separate issue |
|
Awesome! I choose this package for how straighforward it is. Having terms as just strings was a bit too limiting though. Thanks for this PR! |
|
I was also thinking that returned search results should be React components for maximum flexibility. I might take a stab at that. |
|
I think this is a good feature request. Thank you for this PR. I realize this PR is over a month old and I did not have github notifications turned on for repos (I get a lot of gh spam from all my work repos), so this might be old hat. If so, sorry, and thanks for your contribution. I have pushed some changes (mostly formatting + eslint / prettier / dev stuff) so this PR no longer merges cleanly (eslint/precommit hook is a prerequisite if this module is something the world could contribute to). |
I've added functionality for passing objects in as terms (in the shape
{term: string, searchableID?: string, ...}) so the suggestions can be used to return objects, and also allow search-ability by a hidden ID. I've also added a prop toAutoSuggestcalledformatStringto allow for items found using thesearchableIDto be displayed differently to signify how it was found.It's something I've added for my own use, but think it's a useful thing for everyone.
Whether or not you perceive this to be within the scope of the project (or complete enough to be included), thanks for looking.