diff --git a/app/components/admin/settings/map_form_component.html.erb b/app/components/admin/settings/map_form_component.html.erb
index c71b412a0..7a0f00a95 100644
--- a/app/components/admin/settings/map_form_component.html.erb
+++ b/app/components/admin/settings/map_form_component.html.erb
@@ -20,6 +20,7 @@
<%= hidden_field_tag :latitude, Setting["map.latitude"] %>
<%= hidden_field_tag :longitude, Setting["map.longitude"] %>
<%= hidden_field_tag :zoom, Setting["map.zoom"] %>
+ <%= hidden_field_tag :tab, tab if tab %>
<%= submit_tag t("admin.settings.index.map.form.submit"),
diff --git a/app/components/admin/settings/map_form_component.rb b/app/components/admin/settings/map_form_component.rb
index 29e5f5372..81209a7ee 100644
--- a/app/components/admin/settings/map_form_component.rb
+++ b/app/components/admin/settings/map_form_component.rb
@@ -1,2 +1,7 @@
class Admin::Settings::MapFormComponent < ApplicationComponent
+ attr_reader :tab
+
+ def initialize(tab: nil)
+ @tab = tab
+ end
end
diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb
index 13496e212..2778ad3eb 100644
--- a/app/controllers/admin/settings_controller.rb
+++ b/app/controllers/admin/settings_controller.rb
@@ -27,7 +27,7 @@ class Admin::SettingsController < Admin::BaseController
Setting["map.latitude"] = params[:latitude].to_f
Setting["map.longitude"] = params[:longitude].to_f
Setting["map.zoom"] = params[:zoom].to_i
- redirect_to admin_settings_path, notice: t("admin.settings.index.map.flash.update")
+ redirect_to request_referer, notice: t("admin.settings.index.map.flash.update")
end
def update_content_types
diff --git a/app/views/admin/settings/_map_configuration_tab.html.erb b/app/views/admin/settings/_map_configuration_tab.html.erb
index 9f0d4ab71..77130f0a2 100644
--- a/app/views/admin/settings/_map_configuration_tab.html.erb
+++ b/app/views/admin/settings/_map_configuration_tab.html.erb
@@ -5,7 +5,7 @@
<%= t("admin.settings.index.map.help") %>
- <%= render Admin::Settings::MapFormComponent.new %>
+ <%= render Admin::Settings::MapFormComponent.new(tab: "#tab-map-configuration") %>
<% else %>
<%= t("admin.settings.index.map.how_to_enable") %>
diff --git a/spec/system/admin/settings_spec.rb b/spec/system/admin/settings_spec.rb
index 035752740..ad37d80cd 100644
--- a/spec/system/admin/settings_spec.rb
+++ b/spec/system/admin/settings_spec.rb
@@ -222,6 +222,17 @@ describe "Admin settings", :admin do
expect(page).to have_current_path(admin_settings_path)
expect(page).to have_css("div#tab-map-configuration.is-active")
end
+
+ scenario "On #tab-map-configuration when using the interactive map" do
+ visit admin_settings_path(anchor: "tab-map-configuration")
+ within "#map-form" do
+ click_button "Update"
+ end
+
+ expect(page).to have_content("Map configuration updated successfully.")
+ expect(page).to have_current_path(admin_settings_path)
+ expect(page).to have_css("div#tab-map-configuration.is-active")
+ end
end
scenario "On #tab-proposals" do