Page 1 of 1

Dropdown autofocus

Posted: 23 Aug 2022, 11:07
by ricombnation
What is the proper way to autofocus a Dropdown component, so that I can start selecting an entry using the arrow (up / down) keys?

Besides setting the autofocus attribute on the component, I tried stuff like this:

Code: Select all

onMounted(() => {

    nextTick(() => {
     	dropdownRef.focusInput.focus();
	dropdownRef.focused = true;
    })

  }

})
But it does not work - the input only gets focus when I hit tab.

Btw. the behaviour has changed from 3.15 to 3.16. In 3.15, once I hit tab I could select an entry using the arrow keys (the menu / selection does not open). With 3.16.1, when I I hit tab, the input gets focus (blue border), and the menu / selection opens when using the arrow keys. But I cannot select an entry (using the arrow keys).

Re: Dropdown autofocus

Posted: 30 Aug 2022, 13:07
by mert.sincan
Hi,

I've added selectOnFocus option to overlay components in the next version. Details; https://github.com/primefaces/primevue/issues/2902

Best Regards,