DemocracyClub / yournextrepresentative

👥 A website for crowd-sourcing structured election candidate data
https://candidates.democracyclub.org.uk
GNU Affero General Public License v3.0
21 stars 27 forks source link

Make it easier for users to enter results #2420

Closed VirginiaDooley closed 1 month ago

VirginiaDooley commented 1 month ago

Demo https://vimeo.com/984319731/d05951fa88?share=copy

In response to requests for an improved UX for entering results, this PR:

For reference, with two decimal places another electorate is between 71519 and 71531 ps. @Virginia if you end up looking at the ! Enter a number errors, please double check what happens after changing it to a valid value, as I think the error message persists and I've had to re-load that page (then re-enter the value/s)


symroe commented 1 month ago

Nice.

I think both of these fields can have the following:

"onchange": "this.value = Math.round(this.value.replace(/\D/g, '')).toString()",

This removes all non-numeric chars. The reason for this is that as the code stands in this PR we get NaN if you enter a % in the percentage field, something I can see users doing.