bootstrap-combobox icon indicating copy to clipboard operation
bootstrap-combobox copied to clipboard

Combobox doesn't scroll

Open Shujee opened this issue 9 years ago • 5 comments

It looks like the combobox won't scroll up with DOWN arrow key after I type in a few keys and the list of filtered items appears. The selection works fine but goes out of the view without scrolling the list up. I have posted a sample image of the problem at http://stackoverflow.com/questions/26094916/arrow-keys-do-not-work-in-bootstrap-combobox.

Shujee avatar Sep 29 '14 08:09 Shujee

Same thing happening here. Is there any fix for this?

elisamuel40 avatar Feb 03 '15 01:02 elisamuel40

Hey guys, I made a fix for this, maybe not the best, but here is it:

In the "bootstrap-combobox.js" --not the minified version-- find the "move function" (line 317 on version 1.1.6) and replace the cases for "up arroy key" and "down arrow key" with this:

          case 38: // up arrow

          var list = $(e.target.nextSibling.children);
          var index = 0;
          for (var i = 0; i < list.length; i++) {
            if ($(list[i]).hasClass('active')) {
                index = i;
            }
          }
          if (index <= (this.$menu.scrollTop()/26)) {
            this.$menu.scrollTop((index-1)*26)
          } 
          e.preventDefault();
          this.prev();
          break;

        case 40: // down arrow
          e.preventDefault();
          this.next();
          var list = $(e.target.nextSibling.children);
          var index = 0;

          for (var i = 0; i < list.length; i++) {
            if ($(list[i]).hasClass('active')) {
                index = i;
            }
          }
          if (index > (this.$menu.scrollTop()/26)+10) {
            this.$menu.scrollTop((index-10)*26)
          }
          break;

elisamuel40 avatar Feb 04 '15 12:02 elisamuel40

We have same problem as well - posted a screenshot in this ticket https://github.com/hawtio/hawtio-forms/issues/2#issuecomment-88054291

davsclaus avatar Mar 31 '15 12:03 davsclaus

I submitted a pull request with a fix. I used a different method than elisamuel40's because that did not work perfektly for me with long lists, due to the hardcoded pixel values.

lphooge avatar May 07 '15 08:05 lphooge

@lphooge after merging your PR I'm still seeing the issue locally.

wagedomain avatar Jan 16 '16 23:01 wagedomain