Skip to content

Commit

Permalink
Close autopilot modal with esc (#296)
Browse files Browse the repository at this point in the history
* Add `esc` event listener to close autopilot modal

* Check modal is open before `handleCancelAutopilot()`
  • Loading branch information
epilande authored and Max Tyler committed Aug 3, 2016
1 parent 0c773eb commit 0da03a0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/views/map/autopilot.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ class Autopilot extends Component {
const { placesEl } = this.refs
this.placesAutocomplete = places({ container: placesEl })
this.placesAutocomplete.on('change', this.handleSuggestionChange)

window.addEventListener('keyup', ({ keyCode }) => {
if (keyCode === 27 && this.isModalOpen) {
this.handleCancelAutopilot()
}
})
}

@action handleSuggestionChange = ({ suggestion: { latlng: { lat, lng } } }) =>
Expand Down

0 comments on commit 0da03a0

Please sign in to comment.