🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

Issue with locked input fields in Sanity Studio and a solution involving adding a hidden field with a default value.

12 replies
Last updated: Nov 12, 2021
is there a simple fix for locked input fields when using
sanity-input-tabs
? i remember seeing the issue is something to do with a lost focus due to the tabs and can be solved with initial values
Nov 11, 2021, 12:22 PM
Hey User! To clarify, are the fields becoming
readOnly
? In terms of using initial value, just a shot in the dark, but if you set them to something like an empty string does it work?
Nov 12, 2021, 4:53 PM
hi, they are not becoming read only, they look and act like normal input fields but don’t track any input that goes in. this is also happening inside objects without the tabs plugin, so forget that piece
Nov 12, 2021, 6:09 PM
What version of the Studio are you running and can you share an example of the schema where this is happening?
Nov 12, 2021, 6:14 PM
this is happening on one document in particular, and the fields that are not updating are part of an
object
inside the document
Nov 12, 2021, 6:15 PM
i’ve just updated now to the latest version of the studio, i was on an outdated version previously
Nov 12, 2021, 6:21 PM
this is the schema
export default {
	name: 'project',
	title: 'Project',
	type: 'document',
	fields: [
		{
			name: 'video',
			title: 'Video (16:9)',
			type: 'object',
			validation: Rule => Rule.required(),
			fields: [
				{
					title: 'Video URL (16:9)',
					name: 'videoUrl',
					type: 'video',
				},
			],
		},
	],
};
Nov 12, 2021, 6:25 PM
and
video
looks like

export default {
	name: 'video',
	title: 'Video',
	icon: Icon,
	type: 'object',
	fields: [
		{
			name: 'title',
			title: 'Title',
			type: 'string',
		},
		{
			name: 'videoId',
			title: 'Video ID (Vimeo)',
			type: 'string',
			validation: Rule => Rule.required(),
		},
		{
			name: 'showControls',
			title: 'Show Controls?',
			type: 'boolean',
		},
	],
};
Nov 12, 2021, 6:25 PM
Thanks for sharing. Let me see if I can replicate...
Nov 12, 2021, 8:01 PM
I'm not getting the behavior you're describing. Is this happening with all of the documents of the
project
type or a single document of that type?
Nov 12, 2021, 8:06 PM
i figured it out! it was slightly different, but i needed to add a hidden field with a default value inside the object
Nov 12, 2021, 8:21 PM
thanks for your help
Nov 12, 2021, 8:21 PM
Glad you got it sorted out!
Nov 12, 2021, 8:22 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?