Remove description for screen readers

It was being duplicated when restoring a page by using browser
history. With this solution we will avoid to have screen readers
descriptions more than once inside any sociual share button.
This commit is contained in:
Senén Rodero Rodríguez
2020-07-27 12:53:33 +02:00
parent 6b17452bd5
commit 137e0f5a64
3 changed files with 16 additions and 0 deletions

View File

@@ -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);

View File

@@ -5,6 +5,9 @@
$(".social-share-button a").each(function() {
$(this).append("<span class='show-for-sr'>" + ($(this).data("site")) + "</span>");
});
},
destroy: function() {
$(".social-share-button a .show-for-sr").remove();
}
};
}).call(this);

View File

@@ -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