Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

242
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!