Skip to content

Commit a8053e2

Browse files
committed
fix: add disabled state for option
1 parent f414425 commit a8053e2

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

src/Shared/Components/SelectPicker/SelectPicker.component.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ const SelectPicker = <OptionValue, IsMulti extends boolean>({
225225
const labelId = `${inputId}-label`
226226
const errorElementId = `${inputId}-error-msg`
227227

228+
// Option disabled, group null state, checkbox hover, create option visibility (scroll reset on search)
228229
const selectStyles = useMemo(
229230
() =>
230231
getCommonSelectStyle({

src/Shared/Components/SelectPicker/common.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export const SelectPickerOption = <OptionValue, IsMulti extends boolean>({
117117
data,
118118
selectProps: { isMulti },
119119
selectOption,
120+
isDisabled,
120121
} = props
121122
const { description, startIcon, endIcon } = data ?? {}
122123
const showDescription = !!description
@@ -139,6 +140,7 @@ export const SelectPickerOption = <OptionValue, IsMulti extends boolean>({
139140
isChecked={props.isSelected || false}
140141
value={CHECKBOX_VALUE.CHECKED}
141142
rootClassName="mb-0 w-20 p-2 dc__align-self-start dc__no-shrink"
143+
disabled={isDisabled}
142144
/>
143145
)}
144146
<div className={`flex left ${showDescription ? 'top' : ''} dc__gap-8`}>

src/Shared/Components/SelectPicker/utils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ export const getCommonSelectStyle = <OptionValue, IsMulti extends boolean>({
149149
':hover': {
150150
backgroundColor: 'var(--N50)',
151151
},
152+
153+
...(state.isDisabled && {
154+
cursor: 'not-allowed',
155+
// Adding to ensure no active or hover is applied
156+
// backgroundColor: 'var(--N0) !important',
157+
opacity: 0.5,
158+
}),
152159
}),
153160
dropdownIndicator: (base, state) => ({
154161
...base,

0 commit comments

Comments
 (0)