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

466
Views
Cómo arreglar el rol interactivo de 'botón' debe ser enfocable

Tengo una lista de opciones desplegables que el usuario puede seleccionar.

Los optinos en el menú desplegable se hacen con la etiqueta: <a href>:

 <a onClick={() => handleSelect(filter)} role="button"> {filter.name} </a>

El problema es que debo agregar tabIndex="0" or -1 para corregir el error de Eslint.

Pero cuando agrego tabIndex=0 , mi botón ya no funciona.

¿Hay alguna otra forma de corregir este error?

Así es como se ve el componente desplegable:

 <ul name="filters" className="dropdown"> {filterOptions.map((filter) => ( <li key={filter.id} defaultChecked={filter.name} name={filter.name} className={`option option-${filter.selected ? 'selected' : 'unselected'}`} > <span className={`option-${filter.selected ? 'checked-box' : 'unchecked-box'} `} /> <a onClick={() => handleSelect(filter)} role="button"> {filter.name} </a> </li> ))} </ul>
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Los botones son controles interactivos y, por lo tanto, enfocables. Si la función del botón se agrega a un elemento que no se puede enfocar por sí mismo (como <span> , <div> o <p> ), entonces, se debe usar el atributo tabindex para que el botón se pueda enfocar.

https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/button_role#Accessibility_concerns

El atributo HTML tabindex corresponde al atributo tabIndex en React.

https://reactjs.org/docs/dom-elements.html

Así que creo que @S.. la respuesta es correcta:

 <a onClick={() => handleSelect(filter)} role="button" tabIndex={0} > {filter.name} </a>
over 4 years ago · Santiago Trujillo Report

0

Agregar un tabindex:

 <a onClick={() => handleSelect(filter)} role="button" tabIndex={i}> {filter.name} </a>

después de agregar primero un iterador a su mapa: (filter, i)

over 4 years ago · Santiago Trujillo 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!