Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

249
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda