Typing location without selecting returns no search results

HI,

We have successfully implemented the Geolocation add-on to allow searching for Vendors by area. We are using Mapbox as the provider.

When entering text in the area search field, input suggestions appear. Selecting a suggestion works correctly. However, if we enter text directly without selecting a suggestion, the search does not function properly.

In the case of input completion, the value of the element with class="hp-field hp-field--hidden" is populated with location information. This does not seem to happen when input completion is not used.

We understand that this might be the intended behavior. However, we would like to enable searching even when input completion is not used, or alternatively, force the use of input completion.

Could you please advise on any recommended solutions for this issue?

Thank you for your time and assistance.

Hi,

Thanks for the detailed issue report, we have this issue in the bug tracker and plan to fix it in the next update. If it’s urgent, I can provide general dev guidance on how to fix this before the release, by clearing the field if the location is not selected from the drop-down - let me know if this works for you.

Understood. Thank you.

Could you offer some general guidance?

Also, what’s the approximate next release timeframe?

Please check how similar functionality is implemented (the hidden coordinate fields for latitude and longitude are cleared if the text is cleared in the Location field) hivepress-geolocation/assets/js/common.js at master · hivepress/hivepress-geolocation · GitHub You can add similar code, e.g. if the coordinate fields are empty and the user clicks away from the field, then clear the text. Please note that any changes should be also copied to the common.min.js file because this file is loaded (common.js is used for development).

We plan to update Geolocation within 3 weeks or earlier.

Hope this helps

1 Like

Thank you!!

hi

believe this code achieved it.
I’m sharing this for everyone’s benefit.

(function($) {
    $(document).ready(function() {
        // Processing when a blur event occurs on the location search input
        $(document).on('blur', '.hp-field--location input[type="text"]', function() {
            var $locationField = $(this);
            var $latitudeField = $('input[name="latitude"][data-coordinate="lat"]');
            var $longitudeField = $('input[name="longitude"][data-coordinate="lng"]');

            var latitude = $latitudeField.val();
            var longitude = $longitudeField.val();

            if (!latitude || !longitude) {
                $locationField.val('');
            }
        });

        // Processing when the content of the location input field is changed
        $(document).on('input', '.hp-field--location input[type="text"]', function() {
            $('input[name="latitude"][data-coordinate="lat"]').val('');
            $('input[name="longitude"][data-coordinate="lng"]').val('');
        });
    });
})(jQuery);
1 Like

Hi,

Thank you for your solution, it will be useful for our community.

1 Like