Author Topic: Scroll selection into view on dropdown?  (Read 3617 times)

nsomlai

  • Newbie
  • *
  • Posts: 2
    • View Profile
Scroll selection into view on dropdown?
« on: November 10, 2016, 03:01:28 pm »
I'm using single-selection pqSelects on editor forms. When the user edits existing data, they have a selected item when the form is created. My problem is that when clicking the dropdown button, the selected item is not scrolled into view. Is there a way to achieve that? Thanks!

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6307
    • View Profile
Re: Scroll selection into view on dropdown?
« Reply #1 on: November 11, 2016, 04:03:59 pm »
There is no method in pqSelect API to scroll the view.

nsomlai

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Scroll selection into view on dropdown?
« Reply #2 on: November 15, 2016, 12:46:22 pm »
Still testing for side effects, but I think I have found a way.

This function is called with an undefined $label on dropdown:

Code: [Select]
    fn._highlight = function($label) {
        var hoverCls = this.options.hoverCls;
        if (!$label || !$label.length) {
            $label = this.$menu.find("label.pq-select-option-label.ui-state-enable:visible:first");
        }
    ...

Changed the selector and now it seems to work:

Code: [Select]
           
$label = this.$menu.find("label.pq-select-option-label.ui-state-enable.pq-state-select:visible:first");