Meteor-Community-Packages / meteor-autocomplete

Client/server autocompletion designed for Meteor's collections and reactivity.
https://atmospherejs.com/mizzao/autocomplete
MIT License
350 stars 108 forks source link

Making a selection adds a space to the string. #33

Closed lallmon closed 10 years ago

lallmon commented 10 years ago

I'm using autocomplete to pull names of volunteers into a text input.

When I select the name, either clicking or using arrow buttons down, it adds a space to the end of the string.

The expected functionality would be to output a field the same way as it is in the collection , wouldn't it?

Is there a setting or a fix for this?

Thanks

mizzao commented 10 years ago

This has to do with #4 and related issues, including #27. I'll try to change the behavior for single-field autocompletion when I get a chance.

lallmon commented 10 years ago

Ahh yes, I see how that's connected now, and that this library wasn't set up to search a single collection. You can close this issue if you like. Appreciate it.

mizzao commented 10 years ago

I'd also take a PR for anyone who wants to revamp how a single collection autocomplete is handled :D

lallmon commented 10 years ago

I'd like to, though regex isn't really my strong point. I'm a front end engineer, thus why I am looking for something that autocompletes from the DB. :)

mizzao commented 10 years ago

@LucasKA this library is all front end :)

lallmon commented 10 years ago

It's still regexp working on database entries stuff. :)

I thought my specific issue seemed to be in this function: https://github.com/mizzao/meteor-autocomplete/blob/master/autocomplete-client.coffee#L217

@$element.setCursorPosition val.length + 1

I removed the + 1 and it doesn't show up as a having a space, but when you move off the text input, its there when you go back.

For now I just iterated a Select item template over the volunteerName entry. Not nearly as elegant a solution as this, but it is a side project.

mizzao commented 10 years ago

I don't think that line actually inserts the space; the replace inserts the space and that line just goes there. This is the line that inserts the space: https://github.com/mizzao/meteor-autocomplete/blob/master/autocomplete-client.coffee#L223

I don't understand what your last sentence said. So you created a dropdown list instead of using autocomplete?

mizzao commented 10 years ago

0.4.0 overhauls the behavior of what you're trying to do. Give it a try and see if it works for you.