Skip to content

Commit dd7edda

Browse files
committed
[form-builder] Fix wrong previewResolver was passed to FormBuilder
1 parent 40fe45c commit dd7edda

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

packages/@sanity/form-builder/src/FormBuilder.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ function resolve(type, providedResolve = NOOP, defaultResolve = NOOP) {
1919
return undefined
2020
}
2121

22+
function createPatchChannel() {
23+
const channel = pubsub()
24+
return {onPatch: channel.subscribe, receivePatches: channel.publish}
25+
}
26+
2227
export default class FormBuilder extends React.Component {
23-
static createPatchChannel = () => {
24-
const channel = pubsub()
25-
return {receivePatches: channel.publish}
26-
}
28+
static createPatchChannel = createPatchChannel;
2729
static propTypes = {
2830
value: PropTypes.any,
2931
schema: PropTypes.instanceOf(Schema).isRequired,
@@ -68,7 +70,7 @@ export default class FormBuilder extends React.Component {
6870
return {
6971
getValuePath: () => ([]),
7072
formBuilder: {
71-
onPatch: patchChannel ? patchChannel.subscribe : () => {
73+
onPatch: patchChannel ? patchChannel.onPatch : () => {
7274
// eslint-disable-next-line no-console
7375
console.log('No patch channel provided to form-builder. If you need input based patch updates, please provide one')
7476
},

packages/@sanity/form-builder/src/sanity/SanityFormBuilder.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import schema from 'part:@sanity/base/schema'
33

44
import inputResolver from './inputResolver/inputResolver'
55
import SanityPreview from 'part:@sanity/base/preview'
6-
import ValidationList from 'part:@sanity/form-builder/validation-list'
76
import * as patches from '../utils/patches'
87

98
import {FormBuilder, defaultConfig} from '../'
@@ -16,14 +15,17 @@ export {FormBuilderInput} from '../FormBuilderInput'
1615

1716
export {patches}
1817

18+
function previewResolver() {
19+
return SanityPreview
20+
}
21+
1922
export default function SanityFormBuilder(props) {
2023
return (
2124
<FormBuilder
2225
{...props}
2326
schema={schema}
2427
resolveInputComponent={inputResolver}
25-
resolvePreviewComponent={SanityPreview}
26-
resolveValidationComponent={ValidationList}
28+
resolvePreviewComponent={previewResolver}
2729
/>)
2830
}
2931

0 commit comments

Comments
 (0)