3
Meetife
29d

Have anyone experience unexpected behavior using JavaScript? So I wrote this script that manipulate the DOM... however on over clicking a button... Something breaks, however the deadline is tomorrow. Code review is successful. I am sure no sane person will click a button that many times 😅

Comments
  • 5
    Debounce and disable. You needs it. Always implement it, the after click story matters.
  • 2
    @SortOfTested life is what comes after the joke, or something. From Jedi Gym.

    @Meetife "sane person", that means someone in management will do this.
  • 3
    Accessibility problem ahead: people with hand tremor may click several times by accident, though that problem is lessened if you have proper keyboard navigation. You do have that, right?

    As @SortOfTested said, disable the button handler when the button is being handled, and keep around maybe a 100ms guard time before re-enabling it.
  • 2
    @Fast-Nop
    And for buttons that trigger async operations, physically disable the button and provide visual indication that something is processing while they wait.
  • 1
    I use Ladda to help with this.
  • 0
    @spongessuck
    Looks interesting. I generally use something like this so that all components can share a single waitable, and the behavior is decoupled from the button behavior itself:

    https://stackblitz.com/edit/...
  • 1
    @Fast-Nop will definitely implement.
  • 0
    @Demolishun Lol... The code slip
    Through management as it has been approve for production.
  • 0
    @SortOfTested thanks for your suggestion
  • 1
    Unexpected behavior with JavaScript?
    That's a categorical yes.
Add Comment