I have multi-select dropdown, problem is cus when user select one item - dropdown is closed.
How to make that dropdown is closed only on outside click?
Dropdown is made by html ul > li:
// Here we loop trough list of filters and render options as <li> tags
<ul name="filters" className="dropdown">
{subFilters.map((filter, i) => (
<li
defaultChecked={filter.name}
onClick={() => handleSelect(filter)}
className={`option`}>
<span>{filter.name}</span>
</li>
))}
</ul>
Css part - Classes used are:
dropdown
for tagoption
for
.dropdown {
display: flex;
flex-direction: column;
min-width: 11rem;
position: absolute;
z-index: 1;
font-size: 16px;
border-radius: 3px;
border: solid 1px #dee1e5;
box-shadow: 0 9px 8px rgba(0, 0, 0, 0.05);
background-color: white;
outline: none;
cursor: pointer;
}
.option {
list-style-type: none;
padding: 10px 10px 10px 0;
margin-left: 2.6rem;
}