Closed richgcook closed 8 months ago
I've found that when the color input is used as part of an object the predefined colors don't show. I thought this was to do with it being in a collapsed section but forcing collapsed: false doesn't fix the issue.
collapsed: false
No errors in console and no element in the DOM.
import { defineField } from 'sanity' export default defineField({ type: 'color', name: 'colorPicker', title: 'Color', options: { colorList: [ { hex: '#ffffff' }, '#141313', '#f7f1ee', // Beige '#04674a', // Green '#e75f5c', // Red '#eabad8', // Pink '#e4aa58', // Yellow '#4976af', // Blue ] }, })
defineField({ type: 'object', title: 'Colors', name: 'colors', options: { collapsible: true, collapsed: false }, fields: [ defineField({ type: 'colorPicker', title: 'Graphic', name: 'graphic', options: { collapsible: false }, description: 'Used for graphics, if applicable' }), ], }),
On using React Developer Tools it looks like colorList is undefined...
Stupidly this was my own mistake. I was adding the following to the field when used which in turn was overwriting the colorList...
colorList
options: { collapsible: false },
I've found that when the color input is used as part of an object the predefined colors don't show. I thought this was to do with it being in a collapsed section but forcing
collapsed: false
doesn't fix the issue.No errors in console and no element in the DOM.
On using React Developer Tools it looks like colorList is undefined...