-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add option for aligning autocomplete with right edge of input #13
Conversation
Pretty cool ! Isn't there any-way autocomplete.js could automatically detect its best positioning ? |
@jpic, that would be pretty nice, but I don't have the time to look into it, unfortunately. Being able to explicitly define it is nice since automatically detecting doesn't always fit everyone's needs. The parameter could be changed from |
@@ -502,6 +509,7 @@ yourlabs.Autocomplete.prototype.show = function(html) { | |||
// Show the inner and outer container only if necessary. | |||
if (!this.box.is(':visible')) { | |||
this.box.css('display', 'block'); | |||
this.fixPosition(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like fixPosition() could be called twice here, why is it necessary ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's been a few months now so this is hazy in my memory, but I remember there being issues with the box not aligning correctly at times, and adding these two extra calls to fixPosition()
resolved the issue and ensured that the box is always in the correct position (been running this for months and the alignment has been solid).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably the display: block changes the position so we have to fix it again, but it would be nice to avoid calling it twice.
I've added a new commit to this PR after debugging an issue where long text for a text input would push the autocomplete box to the left. This behavior was present on Safari and Chrome, and looks to be because |
Add option for aligning autocomplete with right edge of input
Ok so this works for me, thanks !! |
New option to align the autocomplete box with the right edge of the input rather than the left. Useful for inputs close to the right edge of the screen (like the search box in Django admin).