From 5bc9f4ad81eedecca7b6cdc73c289f6cf3a63dff Mon Sep 17 00:00:00 2001 From: Brad Simpson Date: Thu, 22 Feb 2024 08:44:31 -0700 Subject: [PATCH] New: Add "is-selected" class if an option has been selected (fixes #178) (fixes #179) * Add is-selected class if an option has been selected * Implement hasActiveOption --- templates/matchingDropDown.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/templates/matchingDropDown.jsx b/templates/matchingDropDown.jsx index a3c041e..aed55f5 100644 --- a/templates/matchingDropDown.jsx +++ b/templates/matchingDropDown.jsx @@ -164,6 +164,8 @@ export default function MatchingDropDown(props) { ? correctActiveOption : activeOption; + const hasActiveOption = Boolean(options.find(option => (option._itemIndex === _itemIndex) && option._isActive)); + return (
@@ -171,7 +173,8 @@ export default function MatchingDropDown(props) { disabled={!_isEnabled} className={classes([ 'dropdown__btn js-dropdown-btn', - !_isEnabled && 'is-disabled' + !_isEnabled && 'is-disabled', + hasActiveOption && 'is-selected' ])} aria-haspopup="listbox" aria-expanded={isOpen}