Skip to content

Add community: Enter in the location search runs with an empty query #1422

Description

@escapedcat

Describe the bug
On /communities/add, pressing Enter in the location search always calls the search, including with an empty query or while a search is already running. The Search button is disabled in both states. The search then sends q= to Nominatim, clears the result list, and forgets an area that was already picked. The query is also interpolated into the Nominatim URL unencoded, so &, # or ? in it change the request.

To Reproduce

  1. Open /communities/add and wait for the fields to unlock.
  2. Search for an area and pick a result ("Location selected!").
  3. Clear the search box and press Enter.
  4. The picked area is gone and a q= request went to Nominatim.

Expected behavior
Enter does what the Search button does: nothing while the query is empty or a search is running. Otherwise it runs the search with the query URL-encoded.

Screenshots

Additional context
This predates the inline validation work: main behaves the same. It came up in the review of #1405, which made Enter run only the search (it used to submit the form too). The fix is a guard in searchLocation() plus encodeURIComponent on the query.

Activity

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions