Skip to content

Commit 2f3c38e

Browse files
committed
chore: updated select picker input value
1 parent c74a03d commit 2f3c38e

File tree

5 files changed

+22
-7
lines changed

5 files changed

+22
-7
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "0.3.22-beta-2",
3+
"version": "0.3.22-beta-4",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Shared/Components/SelectPicker/FilterSelectPicker.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@ const FilterSelectPicker = ({
1515
...props
1616
}: FilterSelectPickerProps) => {
1717
const [isMenuOpen, setIsMenuOpen] = useState(false)
18+
const [inputValue, setInputValue] = useState('')
19+
1820
const [selectedOptions, setSelectedOptions] = useState<SelectPickerOptionType[]>(
1921
structuredClone(appliedFilterOptions ?? []),
2022
)
2123

2224
const appliedFiltersCount = appliedFilterOptions?.length ?? 0
2325

26+
const handleInputChange = (_inputValue) => {
27+
setInputValue(_inputValue)
28+
}
29+
2430
useEffect(() => {
2531
setSelectedOptions(appliedFilterOptions ?? [])
2632
}, [appliedFilterOptions])
@@ -39,6 +45,7 @@ const FilterSelectPicker = ({
3945
}
4046

4147
const handleSelectOnChange: SelectPickerProps<number | string, true>['onChange'] = (selectedOptionsToUpdate) => {
48+
setInputValue(inputValue)
4249
setSelectedOptions(structuredClone(selectedOptionsToUpdate) as SelectPickerOptionType[])
4350
}
4451

@@ -85,6 +92,8 @@ const FilterSelectPicker = ({
8592
isClearable={false}
8693
customSelectedOptionsCount={appliedFiltersCount}
8794
icon={filterIcon}
95+
inputValue={inputValue}
96+
onInputChange={handleInputChange}
8897
/>
8998
</div>
9099
)

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ const SelectPicker = <OptionValue, IsMulti extends boolean>({
210210
customSelectedOptionsCount = null,
211211
renderMenuListFooter,
212212
isCreatableSingleSelect = false,
213+
inputValue,
214+
onInputChange,
213215
...props
214216
}: SelectPickerProps<OptionValue, IsMulti>) => {
215217
const { inputId, required, isDisabled, controlShouldRenderValue = true, value, options } = props
@@ -244,8 +246,8 @@ const SelectPicker = <OptionValue, IsMulti extends boolean>({
244246
)
245247

246248
// Used to show the create new option for creatable select and the option(s) doesn't have the input value
247-
const isValidNewOption = (inputValue: string) => {
248-
const trimmedInput = inputValue?.trim()
249+
const isValidNewOption = (_inputValue: string) => {
250+
const trimmedInput = _inputValue?.trim()
249251

250252
return (
251253
isCreatable &&
@@ -310,9 +312,9 @@ const SelectPicker = <OptionValue, IsMulti extends boolean>({
310312
)
311313

312314
const handleCreateOption: SelectPickerProps<OptionValue, true>['multiSelectProps']['onCreateOption'] = (
313-
inputValue,
315+
_inputValue,
314316
) => {
315-
const trimmedInputValue = inputValue?.trim()
317+
const trimmedInputValue = _inputValue?.trim()
316318
if (trimmedInputValue) {
317319
onCreateOption(trimmedInputValue)
318320
}
@@ -444,6 +446,8 @@ const SelectPicker = <OptionValue, IsMulti extends boolean>({
444446
createOptionPosition="first"
445447
onCreateOption={handleCreateOption}
446448
renderMenuListFooter={!optionListError && renderMenuListFooter}
449+
inputValue={inputValue}
450+
onInputChange={onInputChange}
447451
/>
448452
) : (
449453
renderSingleSelectPicker()

src/Shared/Components/SelectPicker/type.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ export type SelectPickerProps<OptionValue = number | string, IsMulti extends boo
100100
| 'autoFocus'
101101
| 'onBlur'
102102
| 'onKeyDown'
103+
| 'onInputChange'
104+
| 'inputValue'
103105
> &
104106
Partial<
105107
Pick<

0 commit comments

Comments
 (0)