@sanity/assist 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/assist",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "sanity",
@@ -91,9 +91,9 @@ export function AssistDocumentForm(props: ObjectInputProps) {
91
91
  }
92
92
  }, [title, documentSchema, onChange, id])
93
93
 
94
- const fieldMissing = fields?.find((f) => f._key !== pathKey)
94
+ const fieldExists = fields?.some((f) => f._key === pathKey)
95
95
  useEffect(() => {
96
- if (onChangeCalled.current || !fieldMissing || activePath || !pathKey) {
96
+ if (onChangeCalled.current || fieldExists || activePath || !pathKey) {
97
97
  return
98
98
  }
99
99
  onChange([
@@ -111,7 +111,7 @@ export function AssistDocumentForm(props: ObjectInputProps) {
111
111
  ),
112
112
  ])
113
113
  onChangeCalled.current = true
114
- }, [activePath, onChange, pathKey, fieldMissing])
114
+ }, [activePath, onChange, pathKey, fieldExists])
115
115
 
116
116
  const {onPathOpen, ...formCallbacks} = useFormCallbacks()
117
117
 
@@ -75,6 +75,18 @@ describe('serializeSchema', () => {
75
75
  ])
76
76
  })
77
77
 
78
+ test('should not serialize slug type', () => {
79
+ const schema = Schema.compile({
80
+ name: 'test',
81
+ types: mockStudioTypes,
82
+ })
83
+
84
+ const serializedTypes = serializeSchema(schema, {leanFormat: true})
85
+
86
+ //everything excluded directly or indirectly
87
+ expect(serializedTypes).toEqual([])
88
+ })
89
+
78
90
  test('should not serialize excluded fields or types or types with every member excluded', () => {
79
91
  const options: AssistOptions = {aiWritingAssistance: {exclude: true}}
80
92