Skip to content

Commit

Permalink
fix: Set correct default for added Resource Mapper boolean fields (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlieKolb authored Dec 23, 2024
1 parent fe7fb41 commit b4c77f2
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -493,14 +493,20 @@ function addField(name: string): void {
if (name === 'removeAllFields') {
return removeAllFields();
}
const schema = state.paramValue.schema;
const field = schema.find((f) => f.id === name);
state.paramValue.value = {
...state.paramValue.value,
[name]: null,
// We only supply boolean defaults since it's a switch that cannot be null in `Fixed` mode
// Other defaults may break backwards compatibility as we'd remove the implicit passthrough
// mode you get when the field exists, but is empty in `Fixed` mode.
[name]: field?.type === 'boolean' ? false : null,
};
const field = state.paramValue.schema.find((f) => f.id === name);
if (field) {
field.removed = false;
state.paramValue.schema.splice(state.paramValue.schema.indexOf(field), 1, field);
schema.splice(schema.indexOf(field), 1, field);
}
emitValueChanged();
}
Expand Down

0 comments on commit b4c77f2

Please sign in to comment.