Skip to content

Commit

Permalink
[form-builder] Make sure slugify always returns a promise
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars committed Feb 22, 2018
1 parent d0eff9f commit 7b6230e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/@sanity/form-builder/src/inputs/Slug/SlugInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default withDocument(

slugify(sourceValue) {
if (!sourceValue) {
return sourceValue
return Promise.resolve(sourceValue)
}

const {type} = this.props
Expand Down Expand Up @@ -113,8 +113,8 @@ export default withDocument(

const newFromSource = typeof source === 'function' ? source(document) : get(document, source)
this.setState({loading: true})
this.slugify(newFromSource)
.then(newSlug => this.updateValue({current: newSlug}))
this.slugify(newFromSource || '')
.then(newSlug => this.updateValue(newSlug))
.catch(err => {
// eslint-disable-next-line no-console
console.error(`An error occured while slugifying "${newFromSource}":\n${err.stack}`)
Expand Down

0 comments on commit 7b6230e

Please sign in to comment.