Improve icon to remove investment from ballot

Note we're absolutely positioning the link instead of the icon; that way
keyboard users will be able to focus on the icon. Until now, users would
focus on an empty link.

For the same reason, we couldn't use `click_link` with Capybara, since
it would fail to click an empty link. Now we can.

Co-authored-by: Javi Martín <javim@elretirao.net>
This commit is contained in:
Alberto
2020-05-16 06:07:41 +02:00
committed by Javi Martín
parent 8be7abe5fd
commit 896fee6e99
3 changed files with 13 additions and 25 deletions

View File

@@ -14,22 +14,15 @@
font-style: italic; font-style: italic;
} }
.remove-investment-project { .remove-budget-investment {
display: block; @include has-fa-icon(times, solid);
height: 0; font-size: rem-calc(20);
position: absolute;
right: rem-calc(6);
top: rem-calc(6);
.icon-x { &::before {
color: #9f9f9f; margin-right: 0;
font-size: rem-calc(24);
line-height: $line-height / 2;
position: absolute;
right: 6px;
text-decoration: none;
top: 6px;
@include breakpoint(medium) {
font-size: $base-font-size;
}
} }
} }
@@ -43,9 +36,5 @@
outline: 0; outline: 0;
text-decoration: none; text-decoration: none;
} }
.remove-investment-project .icon-x {
color: #fff;
}
} }
} }

View File

@@ -5,11 +5,10 @@
<% if budget.balloting? %> <% if budget.balloting? %>
<%= link_to delete_path, <%= link_to delete_path,
title: t("budgets.ballots.show.remove"), title: t("budgets.ballots.show.remove"),
class: "remove-investment-project", class: "remove-budget-investment",
method: :delete, method: :delete,
remote: true do %> remote: true do %>
<span class="show-for-sr"><%= t("budgets.ballots.show.remove") %></span> <span class="show-for-sr"><%= t("budgets.ballots.show.remove") %></span>
<span class="icon-x"></span>
<% end %> <% end %>
<% end %> <% end %>
</li> </li>

View File

@@ -380,7 +380,7 @@ describe "Ballots" do
expect(page).to have_content("You have voted one investment") expect(page).to have_content("You have voted one investment")
within("#budget_investment_#{investment.id}") do within("#budget_investment_#{investment.id}") do
find(".icon-x").click click_link "Remove vote"
end end
expect(page).to have_current_path(budget_ballot_path(budget)) expect(page).to have_current_path(budget_ballot_path(budget))
@@ -407,7 +407,7 @@ describe "Ballots" do
end end
within("#sidebar #budget_investment_#{investment1.id}_sidebar") do within("#sidebar #budget_investment_#{investment1.id}_sidebar") do
find(".icon-x").click click_link "Remove vote"
end end
expect(page).to have_css("#amount-spent", text: "€20,000") expect(page).to have_css("#amount-spent", text: "€20,000")
@@ -437,7 +437,7 @@ describe "Ballots" do
expect(page).to have_content("You have voted one investment") expect(page).to have_content("You have voted one investment")
within(".ballot-list li", text: "Sully monument") do within(".ballot-list li", text: "Sully monument") do
find(".icon-x").click click_link "Remove vote"
end end
expect(page).to have_content("You have voted 0 investments") expect(page).to have_content("You have voted 0 investments")
@@ -627,7 +627,7 @@ describe "Ballots" do
end end
within("#budget_investment_#{bi1.id}_sidebar") do within("#budget_investment_#{bi1.id}_sidebar") do
find(".icon-x").click click_link "Remove vote"
end end
expect(page).not_to have_css "#budget_investment_#{bi1.id}_sidebar" expect(page).not_to have_css "#budget_investment_#{bi1.id}_sidebar"