pablobm left a comment (openstreetmap/openstreetmap-website#6599)

Checking for specific key presses can lead to other issues, accessibility being 
a common example.

The issue is with the form submitting at the wrong moment. Therefore it's 
probably the _submission_ that should be tackled. There's an event for that.

I played a bit with this today. I can't tell this is 100% the best option, 
wondering what others think:

```diff
diff --git a/app/assets/javascripts/language_selector.js 
b/app/assets/javascripts/language_selector.js
index 8380c1b0e..c4bb79821 100644
--- a/app/assets/javascripts/language_selector.js
+++ b/app/assets/javascripts/language_selector.js
@@ -12,3 +12,7 @@ $(document).on("click", "#select_language_dialog 
[data-language-code]", function
     location.reload();
   }
 });
+
+$(document).on("submit", "#select_language_form", function (e) {
+  e.preventDefault();
+});
diff --git a/app/views/languages_panes/show.html.erb 
b/app/views/languages_panes/show.html.erb
index 38a5340f6..82bad7990 100644
--- a/app/views/languages_panes/show.html.erb
+++ b/app/views/languages_panes/show.html.erb
@@ -1,6 +1,6 @@
 <%= turbo_frame_tag "select_language_list" do %>
   <% if current_user&.id %>
-    <%= form_tag basic_preferences_path, :method => "PUT" do %>
+    <%= form_tag basic_preferences_path, :method => "PUT", :id => 
"select_language_form", "data-turbo" => false do %>
       <%= hidden_field_tag "referer", @source_page %>
       <%= hidden_field_tag "language", I18n.locale %>
       <%= render "select_language_list" %>
```

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

Message ID: 
<openstreetmap/openstreetmap-website/pull/6599/[email protected]>
_______________________________________________
rails-dev mailing list
[email protected]
https://lists.openstreetmap.org/listinfo/rails-dev

Reply via email to