Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Immutable fields in the new Copy-Paste feature #7408

Open
anokhjajai opened this issue Aug 22, 2024 · 2 comments
Open

Immutable fields in the new Copy-Paste feature #7408

anokhjajai opened this issue Aug 22, 2024 · 2 comments
Labels

Comments

@anokhjajai
Copy link

Is your feature request related to a problem? Please describe.

The new Copy/Paste feature in Sanity is awesome and is something I wanted for so long.
But it comes with an issue in our current project setup.

We have a hidden, read-only field in our document which gets its value from an initial value template. which means the field gets its value when the document is created and won't change afterward. The value is based on a dynamic parameter which is passed to the initial value template. So the same type of document can have different values based on where they appear on the desk structure.

The issue is that when we copy the whole document and paste it into a different document with the same type but has a different value in the above-mentioned field, the hidden field is also gets overwritten. The value is used for certain processes and this overwrite is messing up that logic.

Describe the solution you'd like

The solution I would suggest is to introduce a flag (like hidden and readOnly) to make the field immutable like the _id and _type properties. So that the copy feature ignores it.

Another solution would be re-use the readOnly flag to make the field immutable.

@runeb runeb added the bug label Sep 9, 2024 — with Linear
@runeb
Copy link
Member

runeb commented Sep 9, 2024

@anokhjajai Just to confirm, is the field marked as read only in your schema, or just hidden?

@anokhjajai
Copy link
Author

anokhjajai commented Sep 9, 2024

@anokhjajai Just to confirm, is the field marked as read only in your schema, or just hidden?

@runeb The field is hidden. Not readonly. But I tried making it readonly, still it is getting overwritten.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants