Use a button instead of a link to remove a marker

Using a button for interactive elements is better, as explained in
commit 5311daadf.

Since buttons with "type=button" do nothing by default, we no longer
need to call `preventDefault()` when clicking it.
This commit is contained in:
Javi Martín
2023-05-02 16:02:27 +02:00
parent 59ed975f81
commit 8b14522bf5
4 changed files with 12 additions and 12 deletions

View File

@@ -33,14 +33,15 @@ class Shared::MapLocationComponent < ApplicationComponent
t("proposals.form.map_remove_marker")
end
def remove_marker_link_id
"remove-marker-link-#{dom_id(map_location)}"
def remove_marker_id
"remove-marker-#{dom_id(map_location)}"
end
def remove_marker
link_to remove_marker_label, "#",
id: remove_marker_link_id,
class: "map-location-remove-marker"
button_tag remove_marker_label,
id: remove_marker_id,
class: "map-location-remove-marker",
type: "button"
end
def data
@@ -52,7 +53,7 @@ class Shared::MapLocationComponent < ApplicationComponent
map_tiles_provider: Rails.application.secrets.map_tiles_provider,
map_tiles_provider_attribution: Rails.application.secrets.map_tiles_provider_attribution,
marker_editable: editable?,
marker_remove_selector: "##{remove_marker_link_id}",
marker_remove_selector: "##{remove_marker_id}",
marker_investments_coordinates: investments_coordinates,
marker_latitude: map_location.latitude.presence,
marker_longitude: map_location.longitude.presence