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

Support for 'no results found' case #74

Closed
oyeanuj opened this issue Jan 9, 2016 · 13 comments
Closed

Support for 'no results found' case #74

oyeanuj opened this issue Jan 9, 2016 · 13 comments

Comments

@oyeanuj
Copy link
Contributor

oyeanuj commented Jan 9, 2016

Hi @ro-ka! Another n00b question:

How do you suggest we handle the case where no result is found in the auto-suggest? Is it possible for the input field to just take the string inputted and pass that as a value (or is that already being done?)

@ro-ka
Copy link
Contributor

ro-ka commented Jan 15, 2016

No problem, there are no n00b questions. ;)

It doesn’t return the entered string – the purpose is to always get a geocoded place from the library to use. When using only the inputted string in the geocoding, the chances of a successful geocode are very low as Google already suggests the known stuff.

Or do you have examples of places that don’t get suggested but can be geocoded by Google?

Related to #72.

@oyeanuj
Copy link
Contributor Author

oyeanuj commented Jan 15, 2016

@ro-ka thanks for the response!

I was coming from it more from a UX point of view, where the following three cases might happen and that I would still like to save the input:

  1. Mis-spellings.
  2. Places not in Google - this is mainly a problem internationally, where either address or place name doesn't show up in Google. From my personal experience, half the places I look up in India might not show up accurately but people around know the place (and hence important to store the place name).
  3. New places, or ones which have psuedo names that they might want to use (again known and understood to the relevant groups even if they can't be geo-coded).

This option would enable the library to provide for input when there are other issues with Google libraries.

What do you think?

@ro-ka
Copy link
Contributor

ro-ka commented Jan 18, 2016

I understand the case. The main purpose is to return a geocoded place to work with. I’m not sure how to integrate the non-geocoding found case.

Possibilities:

  • Default is a strict mode that will only return geocoded places.
  • A non-strict mode could do this:
    • Geocode the input string on enter when nothing is selected.
    • Return geocoded result if something got found.
    • Return without non-geocoded place in case nothing could be geocoded.

Does that make sense?

@oyeanuj
Copy link
Contributor Author

oyeanuj commented Jan 19, 2016

Yes, I think that would work well as it keeps it backward-compatible but provides options to those in need :)

The only question that I have -

Geocode the input string on enter when nothing is selected.

Wondering if the interaction should only be bound to enter. What would you think of having the last row always be the address or a label like "Custom Address" and clicking on that gives you the input string as well?

@ro-ka ro-ka mentioned this issue Feb 5, 2016
@ro-ka
Copy link
Contributor

ro-ka commented Feb 5, 2016

Hm, good question. As there was the request for a submit button in #72, which is the same thing we are talking about here, I’m not sure what to prefer.

A submit button seems to be more standard, but can be confusing. When selecting a suggestion from the dropdown, the submit button is irritating as it doesn’t have any extra functionality. But custom address can be irritation, too.

Will think about that…

@iam4x
Copy link

iam4x commented Mar 30, 2016

I'm using react-geosuggest to validate complete street_address, here's my code:

const filterResults = ({ types }) => !types.includes('street_address')

function SearchLocation(props: Props) {
  const { placeholder, onChange, initialValue, children, precise } = props

    return (
      <div className='search-location'>
        <Geosuggest
          placeholder={ placeholder }
          onSuggestSelect={ (value) => handleChange(value, onChange) }
          initialValue={ initialValue || emptyString }
          types={ precise ? [ 'address' ] : [] }
          skipSuggest={ precise ? filterResults : noop } />
        { children }
      </div>
    )
}

The filter is pretty aggressive and the user must enter an address starting with a number, would be great to display a message when there's no suggestions 👍

Right now, I've wrapped the component to do it myself. If you are ready for a PR @ro-ka I can do it 👍

@oyeanuj
Copy link
Contributor Author

oyeanuj commented Mar 30, 2016

The filter is pretty aggressive and the user must enter an address starting with a number, would be great to display a message when there's no suggestions

That message could be a custom string formed from the input itself.

+1 to @iam4x volunteering for the PR!

But custom address can be irritation, too.
@ro-ka Increasingly, I see this behavior in a lot of places which have address auto-complete since there will always be inputs not on google.

@ro-ka
Copy link
Contributor

ro-ka commented Apr 5, 2016

@iam4x If you like to add a PR that would be great! :)

@ro-ka
Copy link
Contributor

ro-ka commented May 20, 2016

Any progress on this?

@dimafeldman
Copy link
Contributor

I needed a similar functionality too, so here's my PR:
added support for providing a callback when no results found, by simply passing the onSuggestNoResults prop
#167

@oyeanuj
Copy link
Contributor Author

oyeanuj commented Jun 19, 2016

This is awesome, thanks @dimafeldman!

@ro-ka
Copy link
Contributor

ro-ka commented Jun 21, 2016

The PR #167 got merged.

@ro-ka ro-ka closed this as completed Jun 21, 2016
@oyeanuj
Copy link
Contributor Author

oyeanuj commented Dec 5, 2016

@ro-ka Revisiting this, as I was testing some old code and realized that the #167 by @dimafeldman (thank you for that!) only solves part of the issue. That PR allows the developer to get the string entered through the callback function (onSuggestNoResults).

But the other part of this issue was what I think @iam4x, @amanofscience (in #72) and I were also referring to: some way to have a custom label/message in the dropdown which can say "Add [user-input]", clicking on which would fire the callback to onSuggestNoResults added by @dimafeldman.

I was thinking something along the lines of getSuggestLabel, like getSuggestLabelForNoResult? Or do you think we can somehow use that method in this case?

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

No branches or pull requests

5 participants