]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/5898'
authorTom Hughes <tom@compton.nu>
Sun, 6 Apr 2025 14:17:05 +0000 (15:17 +0100)
committerTom Hughes <tom@compton.nu>
Sun, 6 Apr 2025 14:17:05 +0000 (15:17 +0100)
app/assets/javascripts/index.js
app/assets/javascripts/index/new_note.js

index be2a015b344d27a5faaf8db44d0359741d26b788..7ff8a40d1474905b9d706968e75c35b90b22149f 100644 (file)
@@ -278,9 +278,6 @@ $(function () {
       if (params.has("query")) {
         $("#sidebar .search_form input[name=query]").value(params.get("query"));
       }
-      if (!("autofocus" in document.createElement("input"))) {
-        $("#sidebar .search_form input[name=query]").focus();
-      }
       return map.getState();
     };
 
index 1b409846f870848fb48d9871061d71e53ce6b99f..ff4a441263e0b7cc96ba77eef9bc65140da79c97 100644 (file)
@@ -77,7 +77,7 @@ OSM.NewNote = function (map) {
     addHalo(newNoteMarker.getLatLng());
 
     newNoteMarker.on("dragend", function () {
-      content.find("textarea").focus();
+      content.find("textarea").trigger("focus");
     });
   }
 
@@ -87,10 +87,10 @@ OSM.NewNote = function (map) {
     newNoteMarker = null;
   }
 
-  function moveNewNotMarkerToClick(e) {
+  function moveNewNoteMarkerToClick(e) {
     if (newNoteMarker) newNoteMarker.setLatLng(e.latlng);
     if (halo) halo.setLatLng(e.latlng);
-    content.find("textarea").focus();
+    content.find("textarea").trigger("focus");
   }
 
   function updateControls() {
@@ -130,7 +130,9 @@ OSM.NewNote = function (map) {
 
     content.find("textarea")
       .on("input", updateControls)
-      .focus();
+      .attr("readonly", "readonly") // avoid virtual keyboard popping up on focus
+      .trigger("focus")
+      .removeAttr("readonly");
 
     content.find("input[type=submit]").on("click", function (e) {
       const location = newNoteMarker.getLatLng().wrap();
@@ -152,7 +154,7 @@ OSM.NewNote = function (map) {
       });
     });
 
-    map.on("click", moveNewNotMarkerToClick);
+    map.on("click", moveNewNoteMarkerToClick);
     addNoteButton.on("disabled enabled", updateControls);
     updateControls();
 
@@ -160,7 +162,7 @@ OSM.NewNote = function (map) {
   };
 
   page.unload = function () {
-    map.off("click", moveNewNotMarkerToClick);
+    map.off("click", moveNewNoteMarkerToClick);
     addNoteButton.off("disabled enabled", updateControls);
     removeNewNoteMarker();
     addNoteButton.removeClass("active");