diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index d9298762b..184fb3aa2 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -173,6 +173,7 @@ var destroy_non_idempotent_modules = function() { App.Datepicker.destroy(); App.HTMLEditor.destroy(); App.LegislationAnnotatable.destroy(); + App.SocialShare.destroy(); }; $(document).on("turbolinks:load", initialize_modules); diff --git a/app/assets/javascripts/social_share.js b/app/assets/javascripts/social_share.js index 34ae229ac..eb75fe479 100644 --- a/app/assets/javascripts/social_share.js +++ b/app/assets/javascripts/social_share.js @@ -5,6 +5,9 @@ $(".social-share-button a").each(function() { $(this).append("" + ($(this).data("site")) + ""); }); + }, + destroy: function() { + $(".social-share-button a .show-for-sr").remove(); } }; }).call(this); diff --git a/spec/system/proposals_spec.rb b/spec/system/proposals_spec.rb index d0978fa18..cd84e2c5b 100644 --- a/spec/system/proposals_spec.rb +++ b/spec/system/proposals_spec.rb @@ -198,6 +198,18 @@ describe "Proposals" do expect(page).not_to have_link("No comments", href: "#comments") end end + + scenario "After using the browser's back button, social buttons will have one screen reader", :js do + proposal = create(:proposal) + visit proposal_path(proposal) + click_link "Help" + + expect(page).to have_content "CONSUL is a platform for citizen participation" + + go_back + + expect(page).to have_css "span.show-for-sr", text: "twitter", count: 1 + end end describe "Show sticky support button on mobile screens", :js do