Skip to content

Commit

Permalink
Handle no option available case when local body returns empty response (
Browse files Browse the repository at this point in the history
#7359)

* Handle no option available case when result array is empty

* Add Length check validation in rendering Select List

* Add validation in the Select Component
  • Loading branch information
mohanrajnambe authored Apr 2, 2024
1 parent fe6e616 commit 2b71cd3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Components/Form/SelectMenuV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ const SelectMenuV2 = <T, V>(props: SelectMenuProps<T, V>) => {

const showChevronIcon = props.showChevronIcon ?? true;

const placeholder = props.placeholder ?? "Select";
const placeholder =
valueOptions?.length > 0 ? props.placeholder ?? "Select" : "No options";
const defaultOption = {
label: placeholder,
selectedLabel: <p className="font-normal text-gray-600">{placeholder}</p>,
Expand All @@ -77,7 +78,7 @@ const SelectMenuV2 = <T, V>(props: SelectMenuProps<T, V>) => {
return (
<div className={props.className} id={props.id}>
<Listbox
disabled={props.disabled}
disabled={props.disabled || valueOptions?.length === 0}
value={value}
onChange={(selection: any) => props.onChange(selection.value)}
>
Expand Down

0 comments on commit 2b71cd3

Please sign in to comment.