Smart-select scroll to selected value


#1

Would anyone happen to know how to scroll to the input value of a selected item of a smart select auto init when the window appears? I cannot get the position of the selected value to scroll to.
thanks :slight_smile:


#2

This can help to get the required elements:

$$(document).on('smartselect:opened', (e) => {
  var ss = e.detail
  var selectedItems = ss.$containerEl.find('input:checked');
  var pageContent = ss.$containerEl.find('.page-content'); // available in popup/page/sheet
  // scroll page content to selected items
})

#3

Hi Vladimir, and thanks for answering :slight_smile:
I’ve tried that…I always get a position of “0”

I have a smart-select ‘popover’ from 1 to 30 items with closeOnSelect enabled (non-multiple).
When the user clicks and selects 15 the popover closes. When clicked again, it defaults to the top instead of the selected 15. I’ve tried settimeout to allow the popover to appear before reading the position, but all positions display “0”.

thanks
eric


#4

Can you show the code how you detect the position?


#5

…That’s the thing, I cant find the position?!?
not matter what i use to find the position of the selected item, i get value ZERO
ex: $(selectedItems)[0].scrollHeight

thanks!