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

A simple example of old-style behavior or higher-level component? #36

Open
maximsch2 opened this issue Sep 15, 2016 · 7 comments
Open

Comments

@maximsch2
Copy link
Contributor

It seems like new API is vastly more powerful compared to the old one at the expense of being vastly more complicated. I've attempted a migration to it, but now I'm stepping back and re-evaluating to see if it makes sense to do it. For context, I have a bunch of different auto-complete fields in different portions of the web app and manually handling input/query/showMenu stuff is getting reaally boring.

Do you think it makes sense to wrap this around into higher-level component that would embed input and menu and provide functionality similar to the one in the first autocomplete field on the new demo page?

@maximsch2
Copy link
Contributor Author

Something like this (based of AccessibleExample.elm): https://gist.github.com/maximsch2/1dcdb170fd5f2cdb7a3a1b1499cdc62d

@gregziegan
Copy link
Owner

@maximsch2 yes, I actually made this milestone once i released v4 to revisit this and think about how to make drop-in more possible.

https://github.com/thebritican/elm-autocomplete/milestone/3

@gregziegan
Copy link
Owner

Right now, I'd just suggest copy/pasting the AccessibleExample.elm and then customizing it. Nest it in your app. But I want to revisit it very soon! I will read up on your gist soon.

@maximsch2
Copy link
Contributor Author

Sounds good! My gist is actually just an AccessibleExample.elm made a bit more reusable, so might be a good starting point for an embeddable component

@ericgj
Copy link

ericgj commented Sep 27, 2016

I took a crack at a generic-ish version of the AccessibleExample for my needs --
https://gist.github.com/ericgj/a383febb4703715fef44752e29ca3ad3

  • Items must be List (id, item)
  • selectedItem is Maybe id, not Maybe (id, item) .
  • The items are not included in the model but in a Config record that gets passed in to both view and update. In keeping with your second rule of thumb: "Never put any config in your model".

In the common case where your lists of items are loaded separately from the model that has these items as autocomplete selections, where you are likely pulling in the lists of items from further up the state tree from where the model is constructed, it seems to me a lot more flexible to have the list in config. But this seems to cause problems with subscriptions, which I'm putting in a separate issue.

See what you think.

@isaacsanders
Copy link
Contributor

#47 Might be relevant to this discussion

@justgage
Copy link

Yeah this is hurting adoption for me personally.

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

No branches or pull requests

5 participants