Skip to content

Commit 8e76493

Browse files
committed
[B] Ensure sortOrder doesn't trip dirty on resource form
1 parent f05eabf commit 8e76493

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

client/src/backend/containers/resource/Properties.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,17 @@ export class ResourcePropertiesContainer extends PureComponent {
4444
};
4545

4646
render() {
47-
const resource = this.props.resource.attributes;
48-
const t = this.props.t;
47+
const { resource, t } = this.props;
48+
const { attributes } = resource ?? {};
49+
const sortOrderBool = !!attributes?.sortOrder;
50+
4951
return (
5052
<section>
5153
<FormContainer.Form
52-
model={this.props.resource}
54+
model={{
55+
...resource,
56+
attributes: { ...resource.attributes, sortOrder: sortOrderBool }
57+
}}
5358
name="backend-resource-update"
5459
update={resourcesAPI.update}
5560
create={model =>
@@ -69,7 +74,7 @@ export class ResourcePropertiesContainer extends PureComponent {
6974
<Form.Switch
7075
label={t("resources.properties.sort_order_label")}
7176
name="attributes[sortOrder]"
72-
value={!!resource.sortOrder}
77+
value={sortOrderBool}
7378
placeholder={t("resources.properties.sort_order_placeholder")}
7479
instructions={t("resources.properties.sort_order_instructions")}
7580
/>

0 commit comments

Comments
 (0)