Skip to content

Commit

Permalink
New: Add "is-selected" class if an option has been selected (fixes #178
Browse files Browse the repository at this point in the history
…) (fixes #179)

* Add is-selected class if an option has been selected

* Implement hasActiveOption
  • Loading branch information
swashbuck authored Feb 22, 2024
1 parent 98e5c70 commit 5bc9f4a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion templates/matchingDropDown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,17 @@ export default function MatchingDropDown(props) {
? correctActiveOption
: activeOption;

const hasActiveOption = Boolean(options.find(option => (option._itemIndex === _itemIndex) && option._isActive));

return (
<div className="dropdown" disabled={!_isEnabled}>

<button
disabled={!_isEnabled}
className={classes([
'dropdown__btn js-dropdown-btn',
!_isEnabled && 'is-disabled'
!_isEnabled && 'is-disabled',
hasActiveOption && 'is-selected'
])}
aria-haspopup="listbox"
aria-expanded={isOpen}
Expand Down

0 comments on commit 5bc9f4a

Please sign in to comment.