Skip to content

Commit

Permalink
feat: added safe value check to autcomplete (#2811)
Browse files Browse the repository at this point in the history
* feat: added safe value check to autcomplete

* feat: added safe value check to autcomplete

---------

Co-authored-by: Alon Peretz <[email protected]>
  • Loading branch information
chesterkmr and alonp99 authored Nov 2, 2024
1 parent d6cf4ce commit 901a591
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 11 deletions.
7 changes: 7 additions & 0 deletions apps/kyb-app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# kyb-app

## 0.3.73

### Patch Changes

- Updated dependencies
- @ballerine/ui@0.5.41

## 0.3.72

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions apps/kyb-app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ballerine/kyb-app",
"private": true,
"version": "0.3.72",
"version": "0.3.73",
"type": "module",
"scripts": {
"dev": "vite",
Expand All @@ -16,7 +16,7 @@
},
"dependencies": {
"@ballerine/blocks": "0.2.24",
"@ballerine/ui": "0.5.40",
"@ballerine/ui": "0.5.41",
"@ballerine/common": "^0.9.46",
"@ballerine/workflow-browser-sdk": "0.6.58",
"@lukemorales/query-key-factory": "^1.0.3",
Expand Down
7 changes: 7 additions & 0 deletions packages/react-pdf-toolkit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @ballerine/react-pdf-toolkit

## 1.2.41

### Patch Changes

- Updated dependencies
- @ballerine/ui@0.5.41

## 1.2.40

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/react-pdf-toolkit/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ballerine/react-pdf-toolkit",
"private": false,
"version": "1.2.40",
"version": "1.2.41",
"types": "./dist/build.d.ts",
"main": "./dist/react-pdf-toolkit.js",
"module": "./dist/react-pdf-toolkit.mjs",
Expand All @@ -27,7 +27,7 @@
},
"dependencies": {
"@ballerine/config": "^1.1.22",
"@ballerine/ui": "0.5.40",
"@ballerine/ui": "0.5.41",
"@react-pdf/renderer": "^3.1.14",
"@sinclair/typebox": "^0.31.7",
"ajv": "^8.12.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/ui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @ballerine/ui

## 0.5.41

### Patch Changes

- Added safeValue to autocomplete

## 0.5.40

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ballerine/ui",
"private": false,
"version": "0.5.40",
"version": "0.5.41",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ export const AutocompleteInput = ({
onChange,
onBlur,
}: AutocompleteInputProps) => {
const safeValue = useMemo(() => {
if (typeof value !== 'string') {
console.warn('AutocompleteInput: value is not a string', value);
console.warn('Empty string will be used');

return '';
}

return value;
}, [value]);

const optionLabels = useMemo(() => options.map(option => option.value), [options]);

const handleChange: NonNullable<ComponentProps<typeof Autocomplete>['onChange']> = useCallback(
Expand Down Expand Up @@ -66,7 +77,7 @@ export const AutocompleteInput = ({
options={optionLabels}
getOptionLabel={label => label}
freeSolo
inputValue={value}
inputValue={safeValue}
PaperComponent={Paper as ComponentProps<typeof Autocomplete>['PaperComponent']}
onChange={handleChange}
disabled={disabled}
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/workflows-service/prisma/data-migrations

0 comments on commit 901a591

Please sign in to comment.