Skip to content

Commit

Permalink
fix(ui:select): make searchable and fix scroll behaviour (#6303)
Browse files Browse the repository at this point in the history
  • Loading branch information
aweiss-dev committed Jun 17, 2024
1 parent 631efe0 commit 2914431
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
29 changes: 29 additions & 0 deletions packages/react-ui-kit/src/Form/Select.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,34 @@ const [isOpen, setIsOpen] = React.useState(false);
/>
</Column>
</Columns>

<Columns>
<Column>Select with many items</Column>

<Column>
<Select
label="Many items select"
required
id="manyItemsSelect"
options={[...selectOptions, ...selectOptions, ...selectOptions, ...selectOptions]}
dataUieName="required-select"
/>
</Column>
</Columns>

<Columns>
<Column>Searcheable Select</Column>

<Column>
<Select
label="Searchable select"
required
id="searchableSelect"
options={[...selectOptions]}
dataUieName="required-select"
isSearchable
/>
</Column>
</Columns>
</Container>;
```
4 changes: 3 additions & 1 deletion packages/react-ui-kit/src/Form/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ interface SelectProps<IsMulti extends boolean, Group extends GroupBase<Option>>
markInvalid?: boolean;
required?: boolean;
isMulti?: IsMulti;
isSearchable?: boolean;
}

export const Select = <IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>({
Expand All @@ -72,6 +73,7 @@ export const Select = <IsMulti extends boolean = false, Group extends GroupBase<
wrapperCSS = {},
markInvalid = false,
required = false,
isSearchable = false,
...props
}: SelectProps<IsMulti, Group>) => {
const theme = useTheme();
Expand Down Expand Up @@ -111,7 +113,7 @@ export const Select = <IsMulti extends boolean = false, Group extends GroupBase<
tabIndex={TabIndex.UNFOCUSABLE}
isDisabled={disabled}
hideSelectedOptions={false}
isSearchable={false}
isSearchable={isSearchable}
isClearable={false}
closeMenuOnSelect={!isMulti}
isMulti={isMulti}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui-kit/src/Form/SelectStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const customStyles = (theme: Theme, markInvalid = false) => ({
borderRadius: 12,
paddingBottom: 0,
paddingTop: 0,
maxHeight: 'fit-content',
maxHeight: 400,
}),
option: (provided, {isMulti, isDisabled, isFocused, isSelected, options, data}) => ({
...provided,
Expand Down

0 comments on commit 2914431

Please sign in to comment.