Skip to content

Commit

Permalink
Fix link and text selection in budget header
Browse files Browse the repository at this point in the history
While reviewing commit 7702b55, I forgot to test whether selecting
text in the budget header worked properly.

The negative index (-5) meant it was impossible to select its text or
click on its link.

The good news is the pseudoelement with a negative index (-1) is
considered a child of the .budget-header element, so having a negative
index will cause the pseudoelement to be render behind the content of
the .budget-header element but in front of the background of the
.budget-header element.

This is exactly what we want.

Originally, we didn't have a z-index in the .budget-header element,
meaning the pseudoelement was rendered behind the background of the
.budget-header element, meaning both backgrounds were visible. This was
OK when the background was a plain color, but it wasn't when the
background was an image.

To stress the fact that the budget header is only affected when we use
an image, I'm also moving the code inside the `.with-background-image`
selector, although it would be interesting to check whether it's a good
idea to add `z-index: 0` to the `full-width-background` mixin.
  • Loading branch information
javierm committed May 3, 2022
1 parent d05fa80 commit 25ba7fb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/participation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -989,12 +989,12 @@
min-height: $line-height * 25;
padding-bottom: $line-height;
padding-top: $line-height * 4;
z-index: -5;

&.with-background-image {
background-position: center;
background-repeat: no-repeat;
background-size: cover;
z-index: 0;
}

h1 {
Expand Down
9 changes: 9 additions & 0 deletions spec/system/budgets/budgets_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,15 @@

expect(page).to have_content "So far you've supported 0 projects."
end

scenario "Main link takes you to the defined URL" do
budget.update!(main_link_text: "See other budgets!", main_link_url: budgets_path)

visit budget_path(budget)
click_link "See other budgets!"

expect(page).to have_current_path budgets_path
end
end

context "In Drafting phase" do
Expand Down

0 comments on commit 25ba7fb

Please sign in to comment.