My dropdown menu button opens on hover (CSS), but its content is not accessible on the tab.
On button- tab, the dropdown menu opens on next tab press it skips all content of the menu, closes it and continues to go to the next focus elements on the page.
I need to be able to tab through the menu. This from my react component:
<div className="dropdown"
tabIndex="0"
role="navigation">
<button className="dropBtn" tabIndex="0" role="menu" type="button" aria-expanded="false" aria-controls="navbar">
<i className="hover">Places</i>
</button>
<div tabIndex="0" className="dropdown-content">
<div tabIndex='0' className='filter'>
<input
className='input'
tabIndex="0"
type="text"
placeholder="Search your place"
value={this.props.query}
onChange={e => this.props.handleUpdateQuery(e.target.value)}/>
</div>
{/* <div className="search-places-results"> */}
<ul className='listOfPlaces'
role="menubar">
{this.props.filteredPlaces.map((item)=>{
return <li item={item}
tabIndex="0"
role="menuitem"
items={this.props.places}
key={item.id}
onClick={(e)=>{this.props.onItemClick(e, item.id)}}>
{item.name}</li>
})}
</ul>
{/* </div> */}
</div>
</div>
CSS:
.dropdown-content .filter:hover,
.dropdown-content .filter:focus,
.dropdown-content ul li:hover,
.dropdown-content ul li:focus {
background-color: rgb(41, 160, 240);
}
.dropdown:hover .dropdown-content,
.dropdown:focus .dropdown-content {
display: block;
}