Skip to content

Commit 05763dc

Browse files
Handle clear of autocomplete correctly
1 parent a3a0018 commit 05763dc

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

lib/components/Inputs/Autocomplete/Autocomplete.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ export var Autocomplete = function (_a) {
3535
}).field;
3636
var onChange = field.onChange, onBlur = field.onBlur, ref = field.ref, value = field.value;
3737
var handleChange = function (e, newValue, reason) {
38-
onChange(newValue.value);
38+
var _a;
39+
onChange((_a = newValue === null || newValue === void 0 ? void 0 : newValue.value) !== null && _a !== void 0 ? _a : '');
3940
};
4041
var formState = useFormContext().formState;
4142
var errors = formState.errors;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pikobytes/pikobytes-react-forms",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"main": "./lib/index.js",
55
"module": "./lib/index.js",
66
"types": "./lib/index.d.ts",

src/components/Inputs/Autocomplete/Autocomplete.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import parse from 'autosuggest-highlight/parse';
1313
import match from 'autosuggest-highlight/match';
1414

1515

16-
1716
export const Autocomplete = ({
1817
customProperties: { options, registerReturn },
1918
fieldId,
@@ -36,7 +35,7 @@ export const Autocomplete = ({
3635

3736

3837
const handleChange = (e: any, newValue: any, reason: string) => {
39-
onChange(newValue.value);
38+
onChange(newValue?.value ?? '');
4039
};
4140

4241
const { formState } = useFormContext();

0 commit comments

Comments
 (0)