Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use arrow keys to navigate up and down when overflow-y is scrollable #76

Open
ivanakruljac opened this issue Dec 22, 2023 · 1 comment

Comments

@ivanakruljac
Copy link

So, the _onKeyPressed function selects the next element, but if there is overflow-y scroll applied to the ul list,
it doesn't move the position with keycode = 38 and keycode = 40. User needs to use mouse to acually scroll thru list.

This is something that would be very nice to have :)

Many thanks!

Ivana

nice-select2

@Brayn7
Copy link

Brayn7 commented Dec 17, 2024

      const niceSelect = new NiceSelect2(select, {});
      // When niceSelect.dropdown gets the class open. find the li with the class .focus and scrollIntoView
      niceSelect.dropdown.addEventListener('transitionend', () => {
        if (niceSelect.dropdown.classList.contains('open')) {
          const focus = niceSelect.dropdown.querySelector('.focus');
          if (focus) {
            focus.scrollIntoView({ block: 'nearest' });
          }
        }
      });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants