Skip to content
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

When a user clicks the submit button multiple times in quick succession #3309

Closed
santanaalmeida91 opened this issue Jun 22, 2023 · 10 comments
Closed

Comments

@santanaalmeida91
Copy link

I'm experiencing an issue on my project, and I would appreciate some assistance from the community. The problem I'm facing is that when a user clicks the submit button multiple times in quick succession, it leads to the creation of multiple support tickets or requests. This is causing duplication and making it difficult to manage and respond to the tickets effectively.

I was wondering if anyone has encountered a similar situation and could offer some guidance on how to prevent multiple submissions. Is there a way to implement a mechanism that would lock the submit button after the initial click, allowing only one request to be sent at a time?

Any suggestions, code snippets, or insights would be highly appreciated. Thank you in advance for your help!

@btry
Copy link
Collaborator

btry commented Jun 22, 2023

Hi

Formcreator 2.13.6 contains a fix for this problem, but GLPI itself has a bug that you must fix to successfully prevent unwanted form submissions. The informations are in the release notes.

Pick this patch for GLPI: glpi-project/glpi#14418
remove the file glpi/js/common.min.js (feel free to take a backup)
Go the a form where you observed the issue. Refresh the browsers cache with Ctrk+Shift+R (not F5), then try to reproduce. If the patch is properly applied, you should see a spinner when you click for the 1st time on the submit button.

@btry btry added this to the 2.13.6 milestone Jun 22, 2023
@santanaalmeida91
Copy link
Author

I followed the steps you provided, including applying the fix in Formcreator 2.13.6 and removing the "glpi/js/common.min.js" file as instructed. I also made sure to refresh the browser cache using Ctrl+Shift+R and attempted to reproduce the issue. However, I'm still experiencing the problem, and the expected spinner does not appear when I click the submit button for the first time.

I appreciate your assistance so far, but it seems there might be other factors contributing to the issue. Could you please provide further guidance or suggest any additional troubleshooting steps that I can take? I'm eager to resolve this problem and appreciate your support.

Thank you.

@btry
Copy link
Collaborator

btry commented Jun 23, 2023

Hi

including applying the fix in Formcreator 2.13.6

If you use Formcreator 2.13.6, you don't need to patch the plugin as the fix is already in the code.

Could you please provide further guidance or suggest any additional troubleshooting steps that I can take

-Navigate to a form (The preview mode in the forms designer is OK). Open developer tools of your browser and beautify the content of js/common.js . If you don't have this file but have common.min.js then the minified file I asked you to remove is still served or cached.

  • Search in the file with Ctrl+F for the function blockFormSubmit. You should find the following part of the file; notice the line with the red arrow

image

This line shall begin with submitter = form.find (the buggy line begins with submitter = submitter.find)

I expect that for some reason the line is still buggy.

@santanaalmeida91
Copy link
Author

image

@btry
Copy link
Collaborator

btry commented Jun 23, 2023

This is a screen of the file server side. It is not properly patched as I see the faulty line. Please apply the patch then refresh the browser's cache as I described earlier.

@santanaalmeida91
Copy link
Author

image
image

@alessandrocaetanob
Copy link

alessandrocaetanob commented Jun 23, 2023

Hello @btry !

Just to add to Anderson's commentary, the prints he's posting here is after applying the patch in this link: glpi-project/glpi#14418

I've noticed the patch in the link does not moddify the common.js file, that must be why it stays the same after applying it. I will link here some screenshots of the proccess I've used to apply the patch, but I'm certain that this must not be the correct link.

The process I've used is:

wget https://github.com/glpi-project/glpi/pull/14418.diff

Inside the GLPI root folder:

patch -p1 < 14418.diff

The result of the operation:

patching file js/fileupload.js

image

@btry
Copy link
Collaborator

btry commented Jun 23, 2023

Hi @alessandrocaetanob

Then you pointed it out : I gave the URL to an other patch ! Here is the good one : glpi-project/glpi#14646

Sorry for the inconvenience.

@alessandrocaetanob
Copy link

After applying the correct patch, the solution worked, the button now gets blocked after the first click.

We can close this issue now.

@btry
Copy link
Collaborator

btry commented Jun 23, 2023

Great ! thank you for your feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants