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 #114: UK addresses with no locality #116

Merged
merged 1 commit into from
Jun 26, 2020

Conversation

max-nicholson
Copy link
Contributor

As part of the fix, I've had to modify jquery.geocomplete.min.js to add "postal_town" to componentTypes, as without doing this the postal_town in the Google API response won't be saved to the widget - this is a known limitation of the plugin - ubilabs/geocomplete#335

componentTypes is a private property of the plugin, so I couldn't find a way to modify it without modifying the source code directly, but as the repo is archived and unmaintained this seemed like an acceptable solution to me.

In theory if this isn't acceptable, we could potentially look at extending the initDetails method of the plugin (https://github.com/ubilabs/geocomplete/blob/7ce2f83ac4b621b6816f85eaede8f03595e58c9a/jquery.geocomplete.js#L257) and add the updating of the postal_town component, but this seemed much more involved of a change (and not 100% sure it would be possible either).

@banagale
Copy link
Collaborator

First, thanks for doing this and for the test.

I loaded this and was able to run the test successfully.

Just in case, I went to try to submit the test address given in the raw of the test data using the form in the example app. In that case it appears that the js may not be returning the complete dict for the geocoded info from google maps. The result was an address created only with the raw still.

I tried Oxford, UK and Portland, OR and those did come back with full dicts. Would you please double check my test of this using the example site's form?

@max-nicholson
Copy link
Contributor Author

max-nicholson commented Jun 25, 2020

I've run some more tests with UK addresses to double check and the full dicts were populated (using the postal_town as the locality as I'd hope).

I then switched back to develop branch and retried the same raw addresses, and only got the raw field populated.

Lines in yellow done on develop branch using the example_site, white lines done on this feature branch. Note the UK addresses that worked in yellow were at the city level (ie. Oxford, UK and Leamington Spa, UK) - and on my feature branch no new address was created for those as the address ended up being the same

image

Maybe you were using a cached (unchanged) version of the JS if you hadn't done a hard reload before trying the feature branch? Otherwise I'm not sure why the change isn't working for you, any ideas?

@banagale
Copy link
Collaborator

banagale commented Jun 26, 2020

@max-nicholson First, thank you for having another look. I'm ready to accept this PR.

I did think it might be my cache, so I tried it again and inspected sources to be sure I was running the updated JS and I was.

It took me a bit but I believe I've identified a bug (at least in chrome) where in some cases if you can lose the geocoded data that address.js hides in #address-compontents.

The bug appears to be independent of your change and affects all addresses. To repro:

  • Load example site with valid google maps api key
  • Start typing in an address, hit enter to select the top-most highlighted autocomplete
  • Click on the page but not on the submit button

--> Intermittently the data is erased from the name attributes.

This is a whole extra ask, but would you mind trying to repro this bug?

If you don't have time, totally okay--I'll accept this regardless. But if you can also see this happening, it would be good to get some confirmation and it may be something that could affect your project. Regardless I'll also file an issue to either validate this and / or fix this.

Here's an archive with two screen recordings that show the behavior: Archive.zip

You can see it clearly in onchangebug.mp4 at 33 seconds when I click away from the geocoded Foothills address.

The jquery-bug-small.mp4 shows how when this occurs, the locality data does not make it beyond the raw.

I suspect this must be some light async issue that can be resolved in a line or two but I haven't looked at it closely.

@banagale banagale self-assigned this Jun 26, 2020
@banagale banagale added In-Progress This ticket is in active development Normal Medium Priority Ticket labels Jun 26, 2020
@banagale banagale merged commit 35c16cd into furious-luke:develop Jun 26, 2020
Copy link
Collaborator

@banagale banagale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. See comments in PR.

@banagale banagale removed the In-Progress This ticket is in active development label Jun 26, 2020
@banagale
Copy link
Collaborator

I went ahead and merged this and created a new issue, #118 to encapsulate the bug I think I found.

I labeled it Needs Validation, so if you have time to repro that, we can at least know it is a real to-do.

Thanks again for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Normal Medium Priority Ticket
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants