Skip to content

Commit c0ff7e5

Browse files
authored
Merge pull request #499 from mashmatrix/support-slds-2-fix-picklist-item-behaviors-with-no-value
Fix behaviors for `PicklistItem`s with no value for SLDS2
2 parents 7df7d25 + 4b9f3a8 commit c0ff7e5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/scripts/Picklist.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,13 +674,17 @@ export const PicklistItem: FC<PicklistItemProps> = ({
674674
useContext(PicklistContext);
675675
const selected =
676676
selected_ ?? (value != null ? values.indexOf(value) >= 0 : false);
677-
const isFocused = focusedValue === value;
677+
const isFocused = value != null && focusedValue === value;
678678

679679
const onClick = useEventCallback((e: React.SyntheticEvent) => {
680-
if (!disabled && value != null) {
680+
if (disabled) {
681+
return;
682+
}
683+
684+
if (value != null) {
681685
onSelect(value);
682-
onClick_?.(e);
683686
}
687+
onClick_?.(e);
684688
});
685689

686690
const itemClassNames = classnames(

0 commit comments

Comments
 (0)