Honatas / bootstrap-4-autocomplete

A simple autocomplete/typeahead for Bootstrap 4 and jQuery
MIT License
56 stars 31 forks source link

Reposition list when items are shown above input field #30

Open martinstoeckli opened 2 years ago

martinstoeckli commented 2 years ago

When there is not enough place below the input field, the list with the suggestions is correctly placed above the input field. While typing, the list shrinks, but the top left position keeps its place, so there is a growing gap between the list and the input field.

This can be easily overcome by calling update after the open command on line 104.

this.off('keyup.autocomplete').keyup('keyup.autocomplete', function () {
    if (createItems(_field, opts) > 0) {
        _field.dropdown('show');
        _field.dropdown('update'); // <--- This updates the position of the list
    }