Skip to content

Commit a03f125

Browse files
committed
feat: add shouldShowNoOptionsMessage in select picker
1 parent 36553e5 commit a03f125

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ const SelectPicker = <OptionValue, IsMulti extends boolean>({
206206
isCreatable = false,
207207
onCreateOption,
208208
closeMenuOnSelect = false,
209+
shouldShowNoOptionsMessage = true,
209210
...props
210211
}: SelectPickerProps<OptionValue, IsMulti>) => {
211212
const { inputId, required, isDisabled, controlShouldRenderValue = true, value, options } = props
@@ -284,7 +285,11 @@ const SelectPicker = <OptionValue, IsMulti extends boolean>({
284285
return <GenericSectionErrorState reload={reloadOptionList} />
285286
}
286287

287-
return <p className="m-0 cn-7 fs-13 fw-4 lh-20 py-6 px-8">No options</p>
288+
if (shouldShowNoOptionsMessage) {
289+
return <p className="m-0 cn-7 fs-13 fw-4 lh-20 py-6 px-8">No options</p>
290+
}
291+
292+
return null
288293
}
289294

290295
const renderDisabledTippy = (children: ReactElement) => (

src/Shared/Components/SelectPicker/type.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,14 @@ export type SelectPickerProps<OptionValue = number | string, IsMulti extends boo
222222
* @default false
223223
*/
224224
isCreatable?: boolean
225+
/**
226+
* If false, the no options message is not shown
227+
*
228+
* Note: Handling for the menu distortion needs to be handled explicitly in this case
229+
*
230+
* @default true
231+
*/
232+
shouldShowNoOptionsMessage?: boolean
225233
} & (IsMulti extends true
226234
? {
227235
isMulti: IsMulti | boolean

0 commit comments

Comments
 (0)