Skip to content

Commit

Permalink
fix(CanvasForm): Expression form hold stale data
Browse files Browse the repository at this point in the history
When the users includes config in a form field, which has same name as form field of another
language/dataformat type, to which they can switch - the previously configured form field might get omited.

The fix is to assign a key to the form, so React know that the form
should be recreated without reusing the existing fields.

fix: #904
  • Loading branch information
lordrip committed Mar 11, 2024
1 parent 271a29c commit d64fba6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@ export const DataFormatEditor: FunctionComponent<DataFormatEditorProps> = (props
</Dropdown>
{dataFormat && (
<MetadataEditor
key={dataFormat.model.name}
data-testid="dataformat-editor"
name={'dataformat'}
name="dataformat"
schema={dataFormatSchema}
metadata={dataFormatModel}
onChangeModel={(model) => handleOnChange(dataFormat.model.name, model)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,9 @@ export const ExpressionEditor: FunctionComponent<ExpressionEditorProps> = ({
{language && (
<div className="metadata-editor">
<MetadataEditor
key={language.model.name}
data-testid="expression-editor"
name={'expression'}
name="expression"
schema={languageSchema}
metadata={expressionModel}
onChangeModel={(model) => onChangeExpressionModel(language.model.name, model)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ export const LoadBalancerEditor: FunctionComponent<LoadBalancerEditorProps> = (p
{loadBalancer && (
<div className="load-balancer-editor">
<MetadataEditor
key={loadBalancer.model.name}
data-testid="loadbalancer-editor"
name={'loadbalancer'}
name="loadbalancer"
schema={loadBalancerSchema}
metadata={loadBalancerModel}
onChangeModel={(model) => handleOnChange(loadBalancer.model.name, model)}
Expand Down

0 comments on commit d64fba6

Please sign in to comment.