MrSpiffyClean / covidtrends

Tracking the growth of COVID-19 Cases worldwide
https://aatishb.com/covidtrends/
MIT License
0 stars 0 forks source link

Odd behavior with select button #6

Closed MrSpiffyClean closed 4 years ago

MrSpiffyClean commented 4 years ago

Steps to reproduce:

  1. Select Canada
  2. Select Reported Deaths
  3. Press Select All
  4. Select Confirmed Cases

What should be the result:

What happens:

MrSpiffyClean commented 4 years ago

Can reproduce the issue with US, so I'm assuming that it affects every region.

MrSpiffyClean commented 4 years ago

Thinking a bit, and not finding any specific error in code, this might be related to the issue where the selected coutries list is changed after the event firing, which if it is the case, I may not be able to solve easily.

MrSpiffyClean commented 4 years ago

The fix I think can work is treating any change in list of countries as a change of region, so changing the event handler for the Select Parameter should solve this.

MrSpiffyClean commented 4 years ago

The fix works, in that the urlbar no longer shows select after the steps, but it also doesn't correct itself with the now selected countries. Need a fresh set of eyes to do this.

MrSpiffyClean commented 4 years ago

Adding a createURLFromChange call at the end of processData, and shifting some things in the createURL method seems to fix most of this, with one exception: selecting all then passing to the reported deaths ends up creating a large url, but that is equal to a select=all.

Looking further, changing the Parameter (in the selectbox) doesn't seem to change the selectedCountries array, which explains a bit on why select=all isn't being replaced. This is however something by design, so again, unsure on how to proceed.

MrSpiffyClean commented 4 years ago

Adding a third check in the all/nothing part of the createURL might solve the issue. The countries array is changed for the selection, but the selectedCountries stay the same (I think because of ease of comparing one parameter with another?). So, check if all of the elements in countries are in SelectedCountries, if so, change the URL to select=all and be done with it.

MrSpiffyClean commented 4 years ago

Interesting behaviour when changing parameters (verifiable on live page). Change parameters to Reported Deaths, then US, then Reported Cases, then World, then US again and the list of default countries ends up changing (e.g. Louisiana), I believe due to the way the countries/locations are pulled from region selection.