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

171
Views
Focusing a text input using a ref works but focusing a radio input does not

I have a simple React example created here: https://codesandbox.io/s/cocky-browser-bjj9z8?file=/src/App.js

The goal is to have 2 outcomes:

  1. The first button causes the text input to gain focus (this works)
  2. The second button causes the radio input to gain focus (this does not work)

I have implemented the refs and focus events on the buttons in the same way but the radio input does not gain focus for some reason. Attempting to tab and shift+tab through the document will show that both input elements have the ability to be focused.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

maybe you should try to use .click() instead .focus(), something like this


<button tabIndex="-1" onClick={() => radioInputRef.current.click()}>
  Focus radio input
</button>
about 4 years ago · Juan Pablo Isaza Report
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!