Skip to content

fix(document): do not strip editor.hidden fields from document tree#447

Open
surohak wants to merge 2 commits into
nuxt-content:mainfrom
surohak:fix/preserve-hidden-fields-in-document-tree
Open

fix(document): do not strip editor.hidden fields from document tree#447
surohak wants to merge 2 commits into
nuxt-content:mainfrom
surohak:fix/preserve-hidden-fields-in-document-tree

Conversation

@surohak
Copy link
Copy Markdown
Contributor

@surohak surohak commented May 6, 2026

Description

sanitizeDocumentTree deletes all properties marked with editor.hidden in the collection schema from the document object. The original intent was that these fields are auto-generated by modules/hooks and shouldn't appear in the editor.

However, stripping them from the document entirely breaks runtime usage: components and layouts that consume these fields (e.g. computed SEO fields, navigation flags, custom metadata) receive undefined values in preview mode.

Problem

The editor.hidden annotation should only control visibility in the Studio editor UI, not strip data from the document at the data layer. The editor already respects this flag when rendering form fields for editing — the deletion in sanitizeDocumentTree is redundant for editor hiding and harmful for:

  • Preview rendering that depends on these fields
  • Any client-side logic reading the document
  • Comparison logic (causes false change detection since deleted fields don't match source)

Fix

Remove the block in sanitizeDocumentTree that iterates hidden keys and deletes them from the document. This preserves all document data while the editor UI continues to hide these fields from the editing interface as intended.

Changes

  • src/module/src/runtime/utils/document/tree.ts: Remove the editor.hidden key deletion block

sanitizeDocumentTree deletes properties marked with `editor.hidden` in
the collection schema. The intent is that these fields are auto-generated
by modules/hooks and shouldn't appear in the editor.

However, stripping them from the document entirely breaks runtime usage:
components and layouts that consume these fields (e.g. computed SEO
fields, navigation flags, custom meta) receive undefined values.

The `editor.hidden` annotation should only control visibility in the
Studio editor UI, not strip data from the document at the data layer.
The editor already respects this flag when rendering form fields — the
deletion in sanitizeDocumentTree is redundant for editor hiding and
harmful for runtime consumers.

Removing this block preserves all document data while the editor UI
continues to hide these fields from the editing interface.
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 6, 2026

Someone is attempting to deploy a commit to the Nuxt Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant