[openstreetmap/openstreetmap-website] Add datalist to display multiple search results (PR #6765)

Marwin Hochfelsner notifications at github.com
Mon Feb 9 17:40:22 UTC 2026


@hlfan commented on this pull request.



> +    const selectedOption = datalist
+      .find("option")
+      .get()
+      .find(option => option.value === value);
+
+    if (selectedOption) {
+      const lat = selectedOption.getAttribute("data-lat");
+      const lon = selectedOption.getAttribute("data-lon");
+      endpoint.setValue(value, { lat, lon });
+    } else {
+      endpoint.setValue(value);
+    }

Since `.data()` returns `undefined` if there's no match, this can be shortened.

```suggestion
    const latlngObj = datalist
      .find("option")
      .filter((i, option) => option.value === value)
      .first()
      .data();
    endpoint.setValue(value, latlngObj);
```

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6765#pullrequestreview-3774391041
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/6765/review/3774391041 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20260209/c03baf72/attachment.htm>


More information about the rails-dev mailing list