Visible, non-interactive elements with click handlers must have at least one keyboard listener
186 </div>
187 <div className="colleges">
188 {filteredColleges.map((college, index) => (
189 <div190 className={`college ${activeIndex === index ? 'active' : ''}`}191 key={college.id}192 onClick={() => handleCollegeClick(college)}193 onTouchStart={() => handleTouchStart(index)}194 onTouchEnd={handleTouchEnd}195 >196 <div className="college-content">
197 <div className="up">
198 <img className="college-image" src={college.imageURL} alt="College Logo" />
Description
Enforce onClick
is accompanied by at least one of the following: onKeyUp
, onKeyDown
, onKeyPress
. Coding for the keyboard is important for users with physical disabilities who cannot use a mouse, AT compatibility, and screenreader users. This does not apply for interactive or hidden elements
Bad Practice
<div onClick={() => {}} />
Recommended
<div onClick={() => {}} onKeyDown={this.handleKeyDown} />
<div onClick={() => {}} onKeyUp={this.handleKeyUp} />
<div onClick={() => {}} onKeyPress={this.handleKeyPress} />
<button onClick={() => {}} />
<div onClick{() => {}} aria-hidden="true" />