Skip to content
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

Filter on text input #14

Open
bkniffler opened this issue Feb 15, 2017 · 8 comments
Open

Filter on text input #14

bkniffler opened this issue Feb 15, 2017 · 8 comments

Comments

@bkniffler
Copy link
Contributor

bkniffler commented Feb 15, 2017

Hey,
Great plugin!

Currently this plugin doesn't seem to filter items based on what you type after @, e.g. @jo. What would be really cool is a function onFilter that would get the current text and could return a filtered list of items or even fetch new items asynchronously through promise/callback.

What do you think?

edit: Ah, there seems to be such a functionality, need to check it properly.

@aunswjx
Copy link
Contributor

aunswjx commented Feb 15, 2017

Thanks @bkniffler

I think the current implementation of getting the current text is complicate and I think we could make it better. I do like you idea about updating suggestion item via asynchronous call, but I couldn't about a solid solution right now. Currently, what I can think of is adding some kind of setter function of suggestion items to the plugin and pass it to the portal.

What do you think?

Will reopen this issue.

@bkniffler
Copy link
Contributor Author

Hey, my suggestion would be to allow suggestions to be a function that could return an array or a promise, with an argument being the current input (e.g. jon-). Also, on a side note, I would drop either trigger or match, since they do similar things (one being responsible to trigger the whole thing, the other getting the matched text, but they could easily be one regex with @ being default).

@aunswjx
Copy link
Contributor

aunswjx commented Feb 15, 2017

Thank you for your suggestion.

From you suggestion I break it down into the following
New feature

  • Make suggestions prop retrieve value from a function that returns an array or a promise.
  • That function should have current text input as an argument.

Refactor

  • I would drop capture regex since match capture is not really useful.

What do you think? @bkniffler it would be very appreciate, If you could help me on this feature.

@bkniffler
Copy link
Contributor Author

Okay, and I'd try and make use of slate onChange to extrapolate the current input for suggestions. I'll give it a try on weekend.

@oyeanuj
Copy link

oyeanuj commented Feb 27, 2017

Also very interested in this - especially suggestions being a function with the user typed input! @bkniffler let us know if there is even a WIP that one could look at for inspiration.

@bkniffler
Copy link
Contributor Author

Hey @oyeanuj, unfortunately I didn't have the opportunity yet. But its on my backlog as I really need this to work. So if you guys want to give it a shot, go on! If not, expect to see something in the coming weeks :)

@scf4
Copy link

scf4 commented Apr 17, 2017

@bkniffler Any update? This would seem like basic functionality for such a plugin?

@marekolszewski
Copy link

@bkniffler @aunsuwijak I created a PR that adds support for this, but without removing the capture prop. Simply set your suggestions prop to a function that takes the string to be autocompleted and returns a promise, which then resolves to an array matching the existing suggestions prop format.

I've testing it against the Facebook Graph API and the suggestions come in very quickly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants