keystone icon indicating copy to clipboard operation
keystone copied to clipboard

Deleting value in Location field leads to 'Unable to render view'

Open petrkrizek opened this issue 6 years ago • 0 comments

Bug report

Describe the bug

See the title. Error in console: Uncaught TypeError: Cannot destructure property 'googlePlaceID' of 'value' as it is null.

To Reproduce

  1. Create a Location field
  2. Select some address
  3. Delete address
  4. Unable to render view

Expected behaviour

To see map again

The problem

In the file 'packages/fields/src/types/Location/views/Field.js' on line 11 there is destructuring of 'value' that is null. Assigning default value does not help, since null is not undefined. https://github.com/keystonejs/keystone/blob/master/packages/fields/src/types/Location/views/Field.js#L11

The fix

Move the destructuring out from fn argument and add empty object 'fallback' like this:

const { googlePlaceID, formattedAddress, lat, lng } = (value || {})

petrkrizek avatar Jun 28 '20 19:06 petrkrizek