keystone
keystone copied to clipboard
Deleting value in Location field leads to 'Unable to render view'
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
- Create a Location field
- Select some address
- Delete address
- 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 || {})