Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

248
Visualizações
When I have the focus on the dropdown spacebar is not opening my dropdown

I am developing dropdown using Select from rebass. When I am using the keyboard to navigate through page, when I come to the dropdown, and I press space bar or enter, I would like the dropdown to open. I've added a Box container around the dropdown and an onKeyDown event which will directly take the html element through ref and on press of enter or space will open the dropdown. This is how it looks:

<Box
onKeyDown={e => {
     if ((e.Key == "Enter" || e.keyCode == 32) && selectRef =! null && 
          selectRef.current != null) {
          selectRef.current.focus()
     }
   }}>
<Select ref={selectRef}>
....
</Select>
</Box>

When I am navigating through the page with Tab, when the focus is on the dropdown if I press enter the dropdown opens - it works like it suppose to, but if I press space instead, the focus of the dropdown is lost, and the dropdown is not opened. If I press two times on space the dropdown opens. Can someone help me with this? Why the focus is lost when I press once on spacebar? Is there another way to do this (open the dropdown with one press of space)?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda