Skip to content

Commit

Permalink
Use Event data shape containing value instead of plain value (#2945)
Browse files Browse the repository at this point in the history
* sometimes ajv returns equal errors for the same paths
* use "event: {target: {value}}" instead of value
  • Loading branch information
fiskus authored Jul 21, 2022
1 parent 8eabe48 commit c26dfc4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ export default function JsonValidationErrors({
return (
<div className={className}>
{Array.isArray(error) ? (
error.map((e) => (
error.map((e, index) => (
<SingleError
className={classes.item}
error={e}
key={(e as ErrorObject).instancePath + e.message}
key={(e as ErrorObject).instancePath + e.message + index}
/>
))
) : (
Expand Down
10 changes: 8 additions & 2 deletions catalog/app/containers/Bucket/PackageDialog/MetaInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,21 @@ export const MetaInput = React.forwardRef<HTMLDivElement, MetaInputProps>(
const onChangeFullscreen = React.useCallback(
(json: JsonRecord) => {
setJsonInlineEditorKey(R.inc)
onChange(json)
// NOTE: `json` may have `target` field and make react-final-form think it's an event not value
// so, let's create "event" voluntarily
// https://final-form.org/docs/react-final-form/types/FieldRenderProps#inputonchange
onChange({ target: { value: json } })
},
[onChange],
)

const onChangeInline = React.useCallback(
(json: JsonRecord) => {
setJsonFullscreenEditorKey(R.inc)
onChange(json)
// NOTE: `json` may have `target` field and make react-final-form think it's an event not value
// so, let's create "event" voluntarily
// https://final-form.org/docs/react-final-form/types/FieldRenderProps#inputonchange
onChange({ target: { value: json } })
},
[onChange],
)
Expand Down

0 comments on commit c26dfc4

Please sign in to comment.