Always generate <button> tags with button_to
In Rails 6.1 and earlier, `button_to` generated a <button> tag when it received the content as a block, but an <input> tag when receiving the content as the first parameter. That's why we were using blocks with `button_to` most of the time; for starters, <button> tags accept pseudocontent and so are easier to style. In Rails 7.0, `button_to` always generates a <button> tag [1], so we're simplifying the code what uses `button_to`, passing the content as a first parameter instead of passing it as a block. [1] https://guides.rubyonrails.org/v7.1/configuring.html#config-action-view-button-to-generates-button-tag
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<% if button? %>
|
||||
<%= button_to(path, html_options) { text } %>
|
||||
<%= button_to text, path, html_options %>
|
||||
<% else %>
|
||||
<%= link_to text, path, html_options %>
|
||||
<% end %>
|
||||
|
||||
@@ -10,15 +10,14 @@
|
||||
</p>
|
||||
<% end %>
|
||||
<% if investment.should_show_ballots? %>
|
||||
<%= button_to budget_ballot_line_path(id: investment.id,
|
||||
<%= button_to t("budgets.ballots.show.remove"),
|
||||
budget_ballot_line_path(id: investment.id,
|
||||
budget_id: investment.budget_id,
|
||||
investments_ids: investment_ids),
|
||||
class: "button button-remove-support expanded",
|
||||
method: :delete,
|
||||
remote: true,
|
||||
"aria-label": remove_vote_aria_label do %>
|
||||
<%= t("budgets.ballots.show.remove") %>
|
||||
<% end %>
|
||||
"aria-label": remove_vote_aria_label %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
@@ -29,16 +28,15 @@
|
||||
</p>
|
||||
<% end %>
|
||||
<% if investment.should_show_ballots? %>
|
||||
<%= button_to budget_ballot_lines_path(investment_id: investment.id,
|
||||
<%= button_to t("budgets.investments.investment.add"),
|
||||
budget_ballot_lines_path(investment_id: investment.id,
|
||||
budget_id: investment.budget_id,
|
||||
investments_ids: investment_ids),
|
||||
class: "button button-support expanded",
|
||||
title: t("budgets.investments.investment.support_title"),
|
||||
method: :post,
|
||||
remote: true,
|
||||
"aria-label": vote_aria_label do %>
|
||||
<%= t("budgets.investments.investment.add") %>
|
||||
<% end %>
|
||||
"aria-label": vote_aria_label %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -12,13 +12,12 @@
|
||||
<%= t("budgets.investments.votes.already_supported") %>
|
||||
</div>
|
||||
<% if feature?(:remove_investments_supports) %>
|
||||
<%= button_to remove_support_path,
|
||||
<%= button_to t("budgets.investments.votes.remove_support"),
|
||||
remove_support_path,
|
||||
class: "button button-remove-support expanded",
|
||||
method: "delete",
|
||||
remote: true,
|
||||
"aria-label": remove_support_aria_label do %>
|
||||
<%= t("budgets.investments.votes.remove_support") %>
|
||||
<% end %>
|
||||
"aria-label": remove_support_aria_label %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
|
||||
@@ -2,23 +2,21 @@
|
||||
<% if can?(:answer, question) && !question.poll.voted_in_booth?(current_user) %>
|
||||
<% question_answers.each do |question_answer| %>
|
||||
<% if already_answered?(question_answer) %>
|
||||
<%= button_to question_answer_path(question, user_answer(question_answer)),
|
||||
<%= button_to question_answer.title,
|
||||
question_answer_path(question, user_answer(question_answer)),
|
||||
method: :delete,
|
||||
remote: true,
|
||||
title: t("poll_questions.show.voted", answer: question_answer.title),
|
||||
class: "button answered",
|
||||
"aria-pressed": true do %>
|
||||
<%= question_answer.title %>
|
||||
<% end %>
|
||||
"aria-pressed": true %>
|
||||
<% else %>
|
||||
<%= button_to answer_question_path(question, answer: question_answer.title),
|
||||
<%= button_to question_answer.title,
|
||||
answer_question_path(question, answer: question_answer.title),
|
||||
remote: true,
|
||||
title: t("poll_questions.show.vote_answer", answer: question_answer.title),
|
||||
class: "button secondary hollow",
|
||||
"aria-pressed": false,
|
||||
disabled: disable_answer?(question_answer) do %>
|
||||
<%= question_answer.title %>
|
||||
<% end %>
|
||||
disabled: disable_answer?(question_answer) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% elsif !user_signed_in? %>
|
||||
|
||||
@@ -7,14 +7,13 @@
|
||||
<%= t("proposals.proposal.already_supported") %>
|
||||
</div>
|
||||
<% else %>
|
||||
<%= button_to vote_url,
|
||||
<%= button_to t("proposals.proposal.support"),
|
||||
vote_url,
|
||||
class: "button button-support small expanded",
|
||||
title: t("proposals.proposal.support_title"),
|
||||
method: "post",
|
||||
remote: true,
|
||||
"aria-label": support_aria_label do %>
|
||||
<%= t("proposals.proposal.support") %>
|
||||
<% end %>
|
||||
"aria-label": support_aria_label %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
# `button_to` view helper will render `<button>` element, regardless of whether
|
||||
# or not the content is passed as the first argument or as a block.
|
||||
# Rails.application.config.action_view.button_to_generates_button_tag = true
|
||||
Rails.application.config.action_view.button_to_generates_button_tag = true
|
||||
|
||||
# `stylesheet_link_tag` view helper will not render the media attribute by default.
|
||||
# Rails.application.config.action_view.apply_stylesheet_media_default = false
|
||||
|
||||
Reference in New Issue
Block a user