Meteor-Community-Packages / meteor-autocomplete

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

Align the drop-down autocomplete menu with the input box for token-less inputs #55

Closed dandv closed 9 years ago

dandv commented 10 years ago

For token-less inputs, where any character typed in will trigger the autocomplete menu, it seems to make sense to set the menu's left coordinate to the left of the input box. This is how the major search engines display the menu as well, and on narrow screens, this choice would reduce the chance that the menu scrolls off the right edge of the screen. This can be seen on our production autocomplete in the navbar at stockbase.com

image

petrometro commented 10 years ago

:+1: +1 i'd be willing to have a go at this with a few suggestions from the creator...

mizzao commented 10 years ago

You probably just want to amend the positionContainer function in https://github.com/mizzao/meteor-autocomplete/blob/master/autocomplete-client.coffee to return a different position in this case.

It's not trivial how to do this; @dandv has spent a lot of time figuring out the caret position code, and what we basically want is the position of the first character in the input, instead of the caret. You may want to take a look at https://github.com/StockBase/meteor-caret-position as that is where the relevant logic lies, and update that package first.

petrometro commented 10 years ago

ok cheers will give it a go later this week

mizzao commented 9 years ago

@dandv could you try 0.4.9 and tell me if you like it better? You can check out a quick demo at http://autocomplete.meteor.com/.

dandv commented 9 years ago

@mizzao - thanks for making it so easy to try. Looks great! Re. your Sep 8 comment - wouldn't it be enough just to align the dropdown with the input box? (I haven't yet looked at how you implemented it, but maybe updating meteor-caret-position isn't necessary)

mizzao commented 9 years ago

Yeah @cretep did that in #63 already, which is what's implemented now. It's probably better than aligning with the first character anyway.