-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix #4733 path duplication #4735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
import { Component } from 'react'; | ||
import { | ||
getTemplate, | ||
getUiOptions, | ||
orderProperties, | ||
ADDITIONAL_PROPERTY_FLAG, | ||
ANY_OF_KEY, | ||
ErrorSchema, | ||
FieldProps, | ||
FormContextType, | ||
GenericObjectType, | ||
getTemplate, | ||
getUiOptions, | ||
IdSchema, | ||
ONE_OF_KEY, | ||
orderProperties, | ||
PROPERTIES_KEY, | ||
REF_KEY, | ||
RJSFSchema, | ||
StrictRJSFSchema, | ||
TranslatableString, | ||
ADDITIONAL_PROPERTY_FLAG, | ||
PROPERTIES_KEY, | ||
REF_KEY, | ||
ANY_OF_KEY, | ||
ONE_OF_KEY, | ||
} from '@rjsf/utils'; | ||
import Markdown from 'markdown-to-jsx'; | ||
import get from 'lodash/get'; | ||
import has from 'lodash/has'; | ||
import isObject from 'lodash/isObject'; | ||
import set from 'lodash/set'; | ||
import unset from 'lodash/unset'; | ||
import Markdown from 'markdown-to-jsx'; | ||
import { Component } from 'react'; | ||
|
||
/** Type used for the state of the `ObjectField` component */ | ||
type ObjectFieldState = { | ||
|
@@ -80,7 +80,10 @@ class ObjectField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo | |
} | ||
// Copy the current path and insert in the property name into the first location | ||
const changePath = Array.isArray(path) ? path.slice() : []; | ||
changePath.unshift(name); | ||
// Ensure we are not duplicating the path | ||
if (!changePath.length || changePath[0] !== name) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since there is similar code in Can you provide a codesandbox example where you are seeing this problem so that we can better understand why this failed for you. I.e.
|
||
changePath.unshift(name); | ||
} | ||
onChange(value, changePath, newErrorSchema, id); | ||
}; | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this back to the top? We prefer react imports to be first