From c66851f474104b7e9acffba80e0dffe400332fab Mon Sep 17 00:00:00 2001 From: nertc Date: Thu, 4 Jul 2024 16:17:56 +0400 Subject: [PATCH] Share button unusable on a cell phone --- app/assets/javascripts/leaflet.share.js | 1 + app/assets/javascripts/leaflet.sidebar.js | 2 ++ app/assets/stylesheets/common.scss | 4 +-- test/system/index_test.rb | 35 +++++++++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/leaflet.share.js b/app/assets/javascripts/leaflet.share.js index 0b868d2ca..b92d70796 100644 --- a/app/assets/javascripts/leaflet.share.js +++ b/app/assets/javascripts/leaflet.share.js @@ -8,6 +8,7 @@ L.OSM.share = function (options) { control.onAddPane = function (map, button, $ui) { // Link / Embed + $("#content").addClass("overlay-right-sidebar"); var $linkSection = $("
") .attr("class", "share-link p-3 border-bottom border-secondary-subtle") diff --git a/app/assets/javascripts/leaflet.sidebar.js b/app/assets/javascripts/leaflet.sidebar.js index 7e72278e3..9573c839d 100644 --- a/app/assets/javascripts/leaflet.sidebar.js +++ b/app/assets/javascripts/leaflet.sidebar.js @@ -31,9 +31,11 @@ L.OSM.sidebar = function (selector) { map.panBy([-paneWidth, 0], { animate: false }); } $(sidebar).hide(); + $("#content").addClass("overlay-right-sidebar"); current = currentButton = $(); } else { $(sidebar).show(); + $("#content").removeClass("overlay-right-sidebar"); current = pane; currentButton = button || $(); if ($("html").attr("dir") === "rtl") { diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 4cc31d611..7f92b9785 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -395,7 +395,7 @@ body.small-nav { overflow-y: scroll; } - .overlay-sidebar { + .overlay-sidebar.overlay-right-sidebar { #sidebar { position: absolute; width: 350px; @@ -403,7 +403,7 @@ body.small-nav { overflow: hidden; } - #map, #map-ui { + #map { height: 100%; } } diff --git a/test/system/index_test.rb b/test/system/index_test.rb index 1de18c9ed..2944b817e 100644 --- a/test/system/index_test.rb +++ b/test/system/index_test.rb @@ -1,6 +1,41 @@ require "application_system_test_case" class IndexTest < ApplicationSystemTestCase + test "should remove and add an overlay on share button click" do + node = create(:node) + visit node_path(node) + assert_selector "#content.overlay-right-sidebar" + find(".icon.share").click + assert_no_selector "#content.overlay-right-sidebar" + find(".icon.share").click + assert_selector "#content.overlay-right-sidebar" + end + + test "should add an overlay on close" do + node = create(:node) + visit node_path(node) + find(".icon.share").click + assert_no_selector "#content.overlay-right-sidebar" + find(".share-ui .btn-close").click + assert_selector "#content.overlay-right-sidebar" + end + + test "should not add overlay when not closing right menu popup" do + node = create(:node) + visit node_path(node) + find(".icon.share").click + + find(".icon.key").click + assert_no_selector "#content.overlay-right-sidebar" + find(".icon.layers").click + assert_no_selector "#content.overlay-right-sidebar" + find(".icon.key").click + assert_no_selector "#content.overlay-right-sidebar" + + find(".icon.key").click + assert_selector "#content.overlay-right-sidebar" + end + test "node included in edit link" do node = create(:node) visit node_path(node) -- 2.39.5