Skip to content

Commit

Permalink
[desk-tool] Prevent initial value re-render transition
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars committed Oct 24, 2019
1 parent 4665033 commit ce24303
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/@sanity/desk-tool/src/pane/EditorPane.js
Expand Up @@ -2,7 +2,7 @@ import PropTypes from 'prop-types'
import React from 'react'
import promiseLatest from 'promise-latest'
import {merge, concat, timer, of as observableOf} from 'rxjs'
import {catchError, take, mergeMap, switchMap, map, mapTo, tap} from 'rxjs/operators'
import {catchError, switchMap, map, mapTo, tap} from 'rxjs/operators'
import {validateDocument} from '@sanity/validation'
import {omit, throttle, debounce} from 'lodash'
import {FormBuilder, checkoutPair} from 'part:@sanity/form-builder'
Expand Down
8 changes: 7 additions & 1 deletion packages/@sanity/desk-tool/src/utils/withInitialValue.js
Expand Up @@ -151,7 +151,13 @@ export default function withInitialValue(Pane) {
{({draft, published}) => {
const exists = Boolean(draft || published)
if (exists) {
return <Pane {...this.props} />
// Wrap in broken references component to prevent "reload"
// when going from missing document to a document that exists
return (
<BrokenReferences document={{}} type={this.props.options.type} schema={schema}>
<Pane {...this.props} />
</BrokenReferences>
)
}

const {isResolving, initialValue} = this.state
Expand Down

0 comments on commit ce24303

Please sign in to comment.