GithubHelp home page GithubHelp logo

Prevent double-submit of forms about addons HOT 3 CLOSED

Rob--W avatar Rob--W commented on June 16, 2024
Prevent double-submit of forms

from addons.

Comments (3)

andymckay avatar andymckay commented on June 16, 2024

It's rare to see a double form submit prevention scheme that isn't crappy. Doing this requires a bit of work and something I hesitant to recommend we work on. Especially because we plan on re-doing the entire front end of AMO next year to have a different structure, this is one of those things that wouldn't last the transition.

from addons.

andymckay avatar andymckay commented on June 16, 2024

Closing based on last comment.

from addons.

Rob--W avatar Rob--W commented on June 16, 2024

@andymckay
I agree that a general form submission prevention scheme takes a lot of work and rarely results in the desired result, that's why I scoped this bug report to the use case. At the review dashboard on AMO, I frequently see double (and triple!!!) submissions (not just by others, I also commit multiple submissions due to the lag on AMO). The URL is at https://addons.mozilla.org/en-US/editors/review/[addon-id]`

The back-end logic would be something along the lines of:

  1. At form creation time: Include an identifier of the last message (all messages are printed, so this comes at no cost).
  2. At form submission: Query the last row of the message sequence.
  3. If 2 differs from 1, show the form again and ask the user to confirm the submission.

If implemented at the front-end, then I would do:

  1. At form.onsubmit, use event.preventDefault() and request the page using AJAX.
  2. If the last item in the form is equal to the current last element, use an unchecked form.submit().
  3. Otherwise show a warning and request a confirmation.

In both implementations I assume that the data is up-to-date (and not some old cached value).

The logic is not that difficult. If I knew a bit more about the stack that you're using for the backend, then I would have submitted a patch. Given that you're already familiar with the code, is it possible to fix it?

from addons.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.