dxprog / anime-bracket

The code that runs animebracket.com
http://animebracket.com
84 stars 20 forks source link

Votes not consistent after refreshing page #32

Closed Ghostkeeper closed 5 years ago

Ghostkeeper commented 5 years ago

I'm currently voting here: https://animebracket.com/vote/best-girl-6-starting-salt-in-another-contest/ After I submitted my votes, I got a message that the Captcha failed, which is correct because I block scripts from Google by default and so it didn't display that Captcha for me. I temporarily allowed Google in my NoScript which refreshed the page. After the refresh though, the votes that were cast on the candidates were in some cases switched because the candidates are switched from left to right randomly.

Steps to reproduce:

  1. Cast a few votes in a voting page.
  2. Before submitting the votes, refresh the page.

Expected results:

Actual results:

dxprog commented 5 years ago

Thanks for the detailed write up! I can't repro this to save my life, though:

Did a few variations of the above, no dice. This is what I'd expect since selections are not saved between page loads unless those votes have been submitted. What's your browser?

Ghostkeeper commented 5 years ago

Ah, so maybe the bug is then that the selections are not erased when refreshing. If they would be erased, it'll at least be more clear that the votes are not correct any more.

My browser is Firefox 67.0.2, 64-bit on Windows (currently up to date).

dxprog commented 5 years ago

If they would be erased, it'll at least be more clear that the votes are not correct any more.

That's exactly what it does do. As I mentioned in my comment above, only submitted votes are saved between page loads. Nothing else is. I'll give a look in firefox and see if it's trying to be smart but really being dumb.

Ghostkeeper commented 5 years ago

According to this, the form <input> entries get autocompleted when refreshing the page in Firefox, with what the user previously filled in before refreshing. The specification leaves the behaviour here up to the browser. That's probably why the behaviour is different between Firefox and Chrome then.

dxprog commented 5 years ago

Nice catch, man. PR's been merged and pushed to production. Thanks again!

Ghostkeeper commented 5 years ago

It works in production too! Thanks for handling it so quickly.