You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix user feedback on clicking Audit CSV export button #5444
The first idea I came up with would be setting a cookie before calling send_data in the AuditsController#index action.
And then adding a stimulus controller which, once the button is clicked, starts an interval to check if the logic in the format.csv block has been run by checking for the cookie. If so, it would re-enable the button and reset the cookie.
However, by having a closer look at the current logic, I noticed that the button (which actually is an <a> tag) is disabled by using disable_with in the _link_to ui helper:
disable_with seems to be handled by the library @rails/ujs. Below is a screenshot where I inspected the click Event Listener of the "Export Audits" button which led me to the assumption that it is the @rails/ujs library that handles the disabling:
So I started reading about disable_with. In particular, I found this article very helpful. It mentions that when "the request is done, an ajax:complete event will be fired and Rails UJS uses that to re-enable all the elements doing the inverse process".
Currently, the button does not send an AJAX request but it does when adding data-remote="true".
However, we should also consider that when the request is processed very quickly, the user barely gets the time to read the button text:
Aufzeichnung.2025-11-09.141634.mp4
So if we go for this approach, we should find a way to add some delay before the button is re-enabled to avoid the user seeing a flickering button.
Both approaches should be applicable to other Export CSV buttons as well.
What do you think @awwaiid should I proceed with one of the described approaches?
I'd rather make use of something like an Ajax complete event than messing around with setting cookies, which is a lot harder to share across other export buttons.
If we change this to data-remote=true - does the CSV download still work as expected?
My hunch is we should be able to do something with Turbo events if that's what's powering the link.
@dorner Thank you a lot for your thoughts and guidance.
Indeed, I could not get the CSV download working with data-remote=true.
I tried to make use of the Turbo events in the Stimulus controller. However, although Turbo is enabled on that page, it does not seem to handle that request (probably because it is requesting a csv format rather than HTML?).
However, I got a working solution by adding a 'click' EventListener and making an Ajax request in a Stimulus controller. Please find the details in the Draft pull request I added a few minutes ago.
In order to proceed, I would need to know:
if there are implementation details that should be changed,
if a totally different approach should be taken or
if we may go ahead with the current approach.
The current approach has some caveats as described in the linked draft pull request. One of those is that, given that the Ajax request is handled in the Stimulus controller, there seems to be no way to implement a system test (please correct me if I am wrong).
To be honest, I think this is over-engineering a problem that we can fix by just skipping it entirely. If you pass data: { disable_with: false } to the button, it should just not disable it at all. Since this is an export button and isn't executing any write operations, I feel like it's pretty safe to just not do debouncing in this case due to the extra complexity.
I hope everyone is well and that you have had a good start into the new year.
I would still be happy to continue working on this issue.
At the moment, however, I assume we are still waiting for @awwaiid's feedback.
While working on the issue, I too began to wonder how much the described functionality is desired, considering the problems that the implementation would bring with it. Therefore, I agree with what @dorner said.
Activity
[-]<title>[/-][+]Fix user feedback on clicking Audit CSV export button[/+]bellitabellota commentedon Nov 4, 2025
I would like to give this one a try.
cielf commentedon Nov 7, 2025
Please do!
bellitabellota commentedon Nov 9, 2025
send_datain the AuditsController#index action.And then adding a stimulus controller which, once the button is clicked, starts an interval to check if the logic in the
format.csvblock has been run by checking for the cookie. If so, it would re-enable the button and reset the cookie.<a>tag) is disabled by usingdisable_within the_link_toui helper:disable_withseems to be handled by the library @rails/ujs. Below is a screenshot where I inspected the click Event Listener of the "Export Audits" button which led me to the assumption that it is the @rails/ujs library that handles the disabling:So I started reading about
disable_with. In particular, I found this article very helpful. It mentions that when "the request is done, anajax:completeevent will be fired and Rails UJS uses that to re-enable all the elements doing the inverse process".Currently, the button does not send an AJAX request but it does when adding
data-remote="true".However, we should also consider that when the request is processed very quickly, the user barely gets the time to read the button text:
Aufzeichnung.2025-11-09.141634.mp4
So if we go for this approach, we should find a way to add some delay before the button is re-enabled to avoid the user seeing a flickering button.
Both approaches should be applicable to other Export CSV buttons as well.
What do you think @awwaiid should I proceed with one of the described approaches?
dorner commentedon Nov 29, 2025
I'd rather make use of something like an Ajax complete event than messing around with setting cookies, which is a lot harder to share across other export buttons.
If we change this to
data-remote=true- does the CSV download still work as expected?My hunch is we should be able to do something with Turbo events if that's what's powering the link.
bellitabellota commentedon Dec 2, 2025
@dorner Thank you a lot for your thoughts and guidance.
Indeed, I could not get the CSV download working with
data-remote=true.I tried to make use of the Turbo events in the Stimulus controller. However, although Turbo is enabled on that page, it does not seem to handle that request (probably because it is requesting a csv format rather than HTML?).
However, I got a working solution by adding a 'click' EventListener and making an Ajax request in a Stimulus controller. Please find the details in the Draft pull request I added a few minutes ago.
In order to proceed, I would need to know:
The current approach has some caveats as described in the linked draft pull request. One of those is that, given that the Ajax request is handled in the Stimulus controller, there seems to be no way to implement a system test (please correct me if I am wrong).
dorner commentedon Dec 5, 2025
To be honest, I think this is over-engineering a problem that we can fix by just skipping it entirely. If you pass
data: { disable_with: false }to the button, it should just not disable it at all. Since this is an export button and isn't executing any write operations, I feel like it's pretty safe to just not do debouncing in this case due to the extra complexity.@awwaiid thoughts?
github-actions commentedon Jan 5, 2026
This issue is marked as stale due to no activity within 30 days. If no further activity is detected within 7 days, it will be unassigned.
bellitabellota commentedon Jan 5, 2026
I hope everyone is well and that you have had a good start into the new year.
I would still be happy to continue working on this issue.
At the moment, however, I assume we are still waiting for @awwaiid's feedback.
While working on the issue, I too began to wonder how much the described functionality is desired, considering the problems that the implementation would bring with it. Therefore, I agree with what @dorner said.
github-actions commentedon Feb 5, 2026
This issue is marked as stale due to no activity within 30 days. If no further activity is detected within 7 days, it will be unassigned.
github-actions commentedon Feb 13, 2026
Automatically unassigned after 7 days of inactivity.