Skip to content

Commit

Permalink
Merge pull request #4039 from GovAlta/fix/CS-3914
Browse files Browse the repository at this point in the history
fix: set undefined for empty string in jsonforms control
  • Loading branch information
solittlework authored Jan 29, 2025
2 parents d7b3c3c + 71c5b55 commit 3018d66
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ export const GoAInputText = (props: GoAInputTextProps): JSX.Element => {
// maxLength={appliedUiSchemaOptions?.maxLength}
name={appliedUiSchemaOptions?.name || `${id || label}-input`}
testId={appliedUiSchemaOptions?.testId || `${id}-input`}
// Don't use handleChange in the onChange event, use the keyPress or onBlur.
// If you use it onChange along with keyPress event it will cause a
// side effect that causes the validation to render when it shouldn't.
onChange={(name: string, value: string) => {
let formattedValue = value;
if (schema && schema.title === sinTitle && value !== '') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export const onChangeForInputControl = (props: EventChangeControlProps) => {
const { controlProps } = props;
const { handleChange, path } = controlProps;

handleChange(path, value);
handleChange(path, value === '' ? undefined : value);
};

/**
Expand Down

0 comments on commit 3018d66

Please sign in to comment.