Don't disable button to download emails

Rails automatically disables buttons when submitting a form. This works
fine most of the time: for AJAX requests, it enables them again after
the request is complete, and for non-AJAX requests, the button is
replaced by a new element when the new page loads.

However, there's an exception. When a request returns data so users can
download a fire, the request is not an AJAX one and the button is not
replaced. So users are left with a disabled button they can no longer
click.

So in this case, we aren't disabling the button after a user clicks it.
This commit is contained in:
Javi Martín
2020-08-13 17:55:48 +02:00
parent 38ebfed6ea
commit e319b93dc6
2 changed files with 10 additions and 1 deletions

View File

@@ -12,6 +12,8 @@
<%= select_tag :users_segment, options_for_select(user_segments_options) %>
<%= submit_tag t("admin.emails_download.index.download_emails_button"), class: "button" %>
<%= submit_tag t("admin.emails_download.index.download_emails_button"),
class: "button",
data: { disable_with: false } %>
<% end %>
</div>

View File

@@ -38,4 +38,11 @@ describe "Admin download user emails" do
expect(file_contents).to match_array ["admin_news1@consul.dev", "admin_news2@consul.dev"]
end
end
scenario "Download button is not disabled after being clicked", :js do
visit admin_emails_download_index_path
click_button "Download emails list"
expect(page).to have_button "Download emails list", disabled: false
end
end