Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/base/src/formbuilder/editform.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class EditForm extends React.Component<IEditFormProps, any> {
<div>
<h3 style={{ paddingLeft: '5px' }}>Layer Properties</h3>
<LayerForm
key={`${this.props.layer}-${source?.type}`} // Force remount when source type changes
key={`${this.props.layer}-${source?.type}`}
formContext="update"
sourceType={source?.type || 'RasterSource'}
model={this.props.model}
Expand All @@ -112,7 +112,7 @@ export class EditForm extends React.Component<IEditFormProps, any> {
<div>
<h3 style={{ paddingLeft: '5px' }}>Source Properties</h3>
<SourceForm
key={`${this.props.source}-${layer?.type}`} // Force remount when layer type changes
key={`${this.props.source}-${layer?.type}`}
formContext="update"
model={this.props.model}
filePath={this.props.model.filePath}
Expand Down
10 changes: 9 additions & 1 deletion packages/base/src/formbuilder/objectform/baseform.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ const WrappedFormComponent: React.FC<any> = props => {
* It will be up to the user of this class to actually perform the creation/edit using syncdata.
*/
export class BaseForm extends React.Component<IBaseFormProps, IBaseFormStates> {
/** Skip syncData for the initial onChange (RJSF populating form), only sync on user edits. */
private isInitialLoadRef = true;

constructor(props: IBaseFormProps) {
super(props);
this.currentFormData = deepCopy(this.props.sourceData);
Expand All @@ -106,6 +109,7 @@ export class BaseForm extends React.Component<IBaseFormProps, IBaseFormStates> {
this.currentFormData = deepCopy(this.props.sourceData);
const schema = deepCopy(this.props.schema);
this.setState(old => ({ ...old, schema }));
this.isInitialLoadRef = true;
}
}

Expand Down Expand Up @@ -287,7 +291,11 @@ export class BaseForm extends React.Component<IBaseFormProps, IBaseFormStates> {
this.props.formErrorSignal.emit(extraErrors);
}
if (this.props.formContext === 'update') {
this.syncData(this.currentFormData);
if (!this.isInitialLoadRef) {
this.syncData(this.currentFormData);
} else {
this.isInitialLoadRef = false;
}
}
}

Expand Down
Loading