Skip to content

Preserve unknown area properties through edit/save cycle#2

Merged
rovo89 merged 2 commits into
xtech:mainfrom
jrv:preserve_fields
May 13, 2026
Merged

Preserve unknown area properties through edit/save cycle#2
rovo89 merged 2 commits into
xtech:mainfrom
jrv:preserve_fields

Conversation

@jrv
Copy link
Copy Markdown
Contributor

@jrv jrv commented May 11, 2026

Zod was stripping unrecognised fields (e.g. outline_count) from
area.properties at parse time, and AreaSettingsDialog was rebuilding
properties from scratch on save, dropping anything not explicitly listed.

Add .passthrough() to the properties sub-schema so unknown fields survive
parsing, and spread existing feature.properties before overwriting known
fields in AreaSettingsDialog.handleSave.

    Zod was stripping unrecognised fields (e.g. outline_count) from
    area.properties at parse time, and AreaSettingsDialog was rebuilding
    properties from scratch on save, dropping anything not explicitly listed.

    Add .passthrough() to the properties sub-schema so unknown fields survive
    parsing, and spread existing feature.properties before overwriting known
    fields in AreaSettingsDialog.handleSave.
Comment thread src/stores/schemas.ts Outdated
type: z.enum(['mow', 'nav', 'obstacle', 'draft']).default('draft'),
active: z.boolean().default(true),
}),
}).passthrough(),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be better now?

const feature = draw.get(selectedIds[0])!;
const index = features.features.findIndex((f) => f.id === feature.id);
feature.properties = {
...feature.properties,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if there could be an issue where some future, optional properties can't be unset anymore?!?
But generally, I agree that we want to keep additional properties, and obviously we don't know their keys.

@rovo89 rovo89 merged commit 97cd882 into xtech:main May 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants