Skip to content
This repository was archived by the owner on Mar 9, 2021. It is now read-only.

Conversation

@davidsharp
Copy link

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 to AutoSuggest called formatString to allow for items found using the searchableID to 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.

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.
@davidsharp
Copy link
Author

I've also just committed 629c9e8, which highlights a candidate for another styling prop, which should probably be opened as a separate issue

@ross-rosario
Copy link

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!

@ross-rosario
Copy link

I was also thinking that returned search results should be React components for maximum flexibility. I might take a stab at that.

@silesky
Copy link
Owner

silesky commented Dec 24, 2017

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).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants