Cht-core: Debounce form submissions

Created on 14 Nov 2016  路  16Comments  路  Source: medic/cht-core

According to https://github.com/medic/medic-projects/issues/1024#issuecomment-260295712 we are not debouncing our form submissions properly, so users may tap multiple times and have multiple forms created.

We should check this out and replicate it, and then make sure that when you tap the submit button (or other buttons) multiple times the action is only performed once.

Bug UUX

All 16 comments

I'd expect the button to become disabled immediately when pressed, which should prevent this from happening.

Yup me too, but it sounds like, at least from customer reports, that isn't happening. So step 1 would be to confirm those reports by trying to replicate.

This is very difficult to replicate on desktop but fairly easy to replicate on a Tecno Y4, in my experience.

I'm chucking it in the sprint, feel free anyone to override me and drop it back out. My reasoning is that a lack of debouncing is a large and annoying generator of data errors and it shouldn't be hard to fix.

So we definitely have code that theoretically prevents this. Specifically, our current strategy is to set $scope.saving to be true, and for angular's button rendering to disable the submit button if saving is true. I'm not sure if there is some edge case, race condition or other angular issue which means it's not kicking in fast enough and the user is able to get multiple clicks in.

Uhm I think I replicated it O_O:

image

For reference, this was creating a family, with 2 children, and I'm pretty sure I only hit submit 2-3 times before I let the submit button grey out.

So I can't really work out how I got 16 above. Or, even, how I'm managing to get more than one through. Sometimes the debouncing works, sometimes I get two through, and that one time I got 16.

I think the smart move here is to go through all of the save functions and make sure they check their own flag to make sure they don't get fired multiple times instead of trusting angular to do it.

@garethbowen take a gander at that there PR https://github.com/medic/medic-webapp/pull/2922

LGTM.

Sorry guys for taking you back does this mean it's fixed and we will not be seing this duplicates come up due to clicking _submit_ several times? If yes, have we pushed the update? cc @garethbowen & @SCdF ?

@Enock1990 This has been fixed in the master branch which means it will be part of the 2.9.0 release.

@Enock1990 we can chat about this tomorrow, but how urgently does LG need this feature? If it's possible for them to wait for 2.9, let's do that. If they are pushing to get this as soon as possible, we can discuss backporting this feature and releasing 2.8.4.

@sglangevin We will need to delete the duplicates first. I have the duplicates from Michael and have been looking for someone to help me with deleting this to no avail. And yes it is fairly urgent to LG like always!!

@garethbowen it sounds like this is something that is becoming a big issue for LG Kenya in particular. If there is time to do a quick 2.8.4 release with this feature, that would be appreciated.

Seems to be working well for reports and for adding families and people.

Was this page helpful?
0 / 5 - 0 ratings