Skip to content

Commit

Permalink
[google-maps-input] Make remove button actually remove (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoerge committed Oct 19, 2017
1 parent e15fafe commit 9fa5ca6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/@sanity/google-maps-input/src/GeopointInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Button from 'part:@sanity/components/buttons/default'
import Dialog from 'part:@sanity/components/dialogs/default'
import Fieldset from 'part:@sanity/components/fieldsets/default'
import styles from '../styles/GeopointInput.css'
import PatchEvent, {set} from '@sanity/form-builder/PatchEvent'
import PatchEvent, {set, unset} from '@sanity/form-builder/PatchEvent'

const getLocale = context => {
const intl = context.intl || {}
Expand Down Expand Up @@ -61,6 +61,11 @@ class GeopointInput extends React.Component {
})))
}

handleClear = () => {
const {onChange} = this.props
onChange(PatchEvent.from(unset()))
}

handleCloseModal() {
this.setState({modalOpen: false})
}
Expand Down Expand Up @@ -117,7 +122,7 @@ class GeopointInput extends React.Component {
</Button>

{value && (
<Button type="button">
<Button type="button" onClick={this.handleClear}>
Remove
</Button>
)}
Expand Down

0 comments on commit 9fa5ca6

Please sign in to comment.