@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/[email protected]>
_______________________________________________
rails-dev mailing list
[email protected]
https://lists.openstreetmap.org/listinfo/rails-dev

Reply via email to