-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[backend] Disable submit buttons after first click #3342
[backend] Disable submit buttons after first click #3342
Conversation
backend/spec/features/admin/configuration/shipping_methods_spec.rb
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nice feature. Thanks.
I only have some notes about the specs for this. We should use the existing specs to test this feature and should not add multiple additional it
blocks
select Spree::PaymentMethod::Check.model_name.human, from: "Type" | ||
click_button "Create" | ||
|
||
expect(find('input[type="submit"]')).to be_disabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we move this into the other spec instead? We should avoid to have multiple it
blocks in feature specs. This unnecessarily slows down our test suite
|
||
click_on "Create" | ||
|
||
expect(find('input[type="submit"]')).to be_disabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tvdeyen I updated the files according to your suggestion. I think they don't read as good as before, so we're loosing something here. But I agree that saving some seconds is a good thing, so why not 👍
|
||
create_code_batch | ||
|
||
expect(find('input[type="submit"]')).to be_disabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don’t need multiple it blocks to test this feature.
This is also an issue in areas where double click occurs on refunds for example. It will double refund. We solved this on our store and you ( @spaghetticode ) actually fixed the issue we spec'd out for you . Dec 2018 Modded Euros issue 870 in our codebase for reference |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This a good idea. I agree with @tvdeyen, but I'd also be okay with merging this as it is -- it is a pretty big UX improvement in my opinion.
Thanks @spaghetticode ❤🍝
5ca9607
to
4c30bd5
Compare
Disabling the button prevents multiple form submissions that may result in errors, as it generally does not make any sense creating multiple customer returns starting from the same data.
Disabling the button prevents multiple form submissions that would result in unwanted duplicated records.
Some modifications to `click_nav` have been done in order to make that helper method work with Selenium JS tests as well.
Disabling the button prevents multiple form submissions that would result in unwanted duplicated records.
Disabling the button prevents multiple form submissions that would result in unwanted duplicated records.
Disabling the button prevents multiple form submissions that would result in duplicate error messages.
Disabling the button prevents multiple form submission that would result in unwanted duplicated records.
This partial is used by many `create` forms in the admin. Disabling the button prevents multiple form submissions that would result in unwanted duplicated records or errors.
4c30bd5
to
192cac5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good change! We can keep iterating going forward
Description
It may happen that admin users click multiple times (purposely or not) on submit buttons in the backend area.
This can be a problem as at times it may silently generate unwanted duplicate records, or show an error page due to duplicate records. This is much more likely to happen on real shops when unanticipated server load makes the application unresponsive (at first click nothing seems to happen, so then why not click again?) and where some controller
create
actions may be patched and be slower.By changing
button_tag
tof.submit
orsubmit_tag
the button gets disabled after the first click, thanks to the automatically added attributedata-disable-with="Create"
Checklist: