Skip to content

Commit 101d1f4

Browse files
committed
feat: expose onBlur and trim value in create option
1 parent 9dc251c commit 101d1f4

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
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.2.9-beta-1",
3+
"version": "0.2.9-beta-2",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,15 @@ const SelectPicker = <OptionValue, IsMulti extends boolean>({
311311
</Tippy>
312312
)
313313

314+
const handleCreateOption: SelectPickerProps<OptionValue, true>['multiSelectProps']['onCreateOption'] = (
315+
inputValue,
316+
) => {
317+
const trimmedInputValue = inputValue?.trim()
318+
if (trimmedInputValue) {
319+
onCreateOption(trimmedInputValue)
320+
}
321+
}
322+
314323
const commonProps = useMemo(
315324
() => ({
316325
name: name || inputId,
@@ -388,7 +397,7 @@ const SelectPicker = <OptionValue, IsMulti extends boolean>({
388397
allowCreateWhileLoading={false}
389398
isValidNewOption={isValidNewOption}
390399
createOptionPosition="first"
391-
onCreateOption={onCreateOption}
400+
onCreateOption={handleCreateOption}
392401
/>
393402
) : (
394403
<ReactSelect

src/Shared/Components/SelectPicker/type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export type SelectPickerProps<OptionValue = number | string, IsMulti extends boo
7171
| 'onMenuOpen'
7272
| 'onMenuClose'
7373
| 'autoFocus'
74+
| 'onBlur'
7475
> &
7576
Required<Pick<SelectProps<OptionValue, IsMulti>, 'inputId'>> & {
7677
/**

0 commit comments

Comments
 (0)