Skip to content

Commit

Permalink
geocode bug fixed, but it's not setting id to -1
Browse files Browse the repository at this point in the history
  • Loading branch information
nimmolo committed Aug 3, 2024
1 parent 71cfe0a commit d80e74a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions app/javascript/controllers/geocode_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ export default class extends Controller {
const extents = results[0].geometry.bounds?.toJSON() // may not exist
const center = results[0].geometry.location.toJSON()

if (viewport)
this.map.fitBounds(viewport)
if (this.map)
this.placeClosestRectangle(viewport, extents)
if (this.map) {
if (viewport) this.map.fitBounds(viewport)
this.placeClosestRectangle(viewport, extents) // viewport is optional
}
this.updateFields(viewport, extents, center)
// For non-autocompleted place input in the location form
this.updatePlaceInputTarget(results[0])
Expand Down
6 changes: 5 additions & 1 deletion app/views/controllers/herbaria/_form.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ end

<%= form_with(
model: @herbarium, id: "herbarium_form", class: "geocode-outlet",
data: { controller: "geocode" }
data: {
controller: "geocode",
action:
"autocompleter:hiddenIdDataChanged@window->geocode#geolocatePlaceName"
}
) do |f| %>

<%= submit_button(form: f, button: button_name, center: true) %>
Expand Down

0 comments on commit d80e74a

Please sign in to comment.