Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Guard against 'null' description when losing focus (fixes #19) #20

Merged
merged 1 commit into from
Jan 30, 2018

Conversation

Giners
Copy link
Owner

@Giners Giners commented Jan 30, 2018

There is an issue where if you search and render suggestions for the first time (i.e. a suggestion hasn't been selected yet) and click away so that focus is lost then you will receive an error of the form: "Uncaught TypeError: Cannot read property 'description' of null".

This error occurs in the function we pass to the 'itemToString' prop when rendering the component. Its a result of no suggestions being available yet trying to destructure the 'description' property off of a suggestion.

This commit provides a fix to guard against the case where there are no suggestions, in which case we simply return the empty string.

This PR fixes bug: #19

There is an issue where if you search and render suggestions for the
first time (i.e. a suggestion hasn't been selected yet) and click away
so taht focus is lost then you will receive an error of the form:
"Uncaught TypeError: Cannot read property 'description' of null". This
error occurs in the function we pass to the 'itemToString' prop when
rendering the <Downshift> component. Its a result of no suggestions
being available yet trying to destructure the 'description' property off
of a suggestion.

This commit provides a fix to guard against the case where there are no
suggestions, in which case we simply return the empty string.
	modified:   src/MUIPlacesAutocomplete.jsx
@Giners Giners merged commit 27336be into master Jan 30, 2018
@Giners Giners deleted the fix/itemToString-null-description branch January 31, 2018 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants