Commit e37b3e2fcc710067c74d00d3d89f4bfb05276d6f
1 parent
85cd639c
Exists in
master
and in
29 other branches
tokeninput: don't focus on init to avoid page scroll down
This happens for example on /admin/features with feature members_whitelist_enabled with one member added, the page will load and scroll to token input
Showing
1 changed file
with
6 additions
and
6 deletions
Show diff stats
public/javascripts/jquery.tokeninput.js
... | ... | @@ -345,7 +345,7 @@ $.TokenList = function (input, url_or_data, options) { |
345 | 345 | dropdown.appendTo("body"); |
346 | 346 | if (!settings.permanentDropdown) |
347 | 347 | dropdown.appendTo("body"); |
348 | - else | |
348 | + else | |
349 | 349 | $(input).after(dropdown.show()); |
350 | 350 | |
351 | 351 | if (settings.permanentDropdown || settings.showAllResults) { |
... | ... | @@ -382,7 +382,7 @@ $.TokenList = function (input, url_or_data, options) { |
382 | 382 | if(li_data && li_data.length) { |
383 | 383 | $.each(li_data, function (index, value) { |
384 | 384 | insert_token(value); |
385 | - checkTokenLimit(); | |
385 | + checkTokenLimit({init: true}); | |
386 | 386 | }); |
387 | 387 | } |
388 | 388 | |
... | ... | @@ -425,12 +425,12 @@ $.TokenList = function (input, url_or_data, options) { |
425 | 425 | // Private functions |
426 | 426 | // |
427 | 427 | |
428 | - function checkTokenLimit() { | |
428 | + function checkTokenLimit(options) { | |
429 | 429 | if(settings.tokenLimit !== null && token_count >= settings.tokenLimit) { |
430 | 430 | input_box.hide(); |
431 | 431 | hide_dropdown(); |
432 | 432 | return; |
433 | - } else { | |
433 | + } else if (options && !options.init) { | |
434 | 434 | input_box.focus(); |
435 | 435 | } |
436 | 436 | } |
... | ... | @@ -618,7 +618,7 @@ $.TokenList = function (input, url_or_data, options) { |
618 | 618 | if (!settings.showAllResults) |
619 | 619 | dropdown.empty(); |
620 | 620 | selected_dropdown_item = null; |
621 | - } | |
621 | + } | |
622 | 622 | if (settings.showAllResults) |
623 | 623 | show_dropdown_hint(); |
624 | 624 | } |
... | ... | @@ -728,7 +728,7 @@ $.TokenList = function (input, url_or_data, options) { |
728 | 728 | item.addClass(settings.classes.selectedDropdownItem); |
729 | 729 | selected_dropdown_item = item.get(0); |
730 | 730 | |
731 | - isBefore = item[0].offsetTop <= (dropdown[0].scrollTop + dropdown[0].scrollWidth); | |
731 | + isBefore = item[0].offsetTop <= (dropdown[0].scrollTop + dropdown[0].scrollWidth); | |
732 | 732 | isAfter = item[0].offsetTop >= dropdown[0].scrollTop; |
733 | 733 | visible = isBefore && isAfter; |
734 | 734 | if (!visible) { | ... | ... |