New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Race & Ethnicities (Playtesting Followup): Debounce Saving & Send All Dimensions #174
Conversation
70c3eb7
to
28ceb3a
Compare
Further optimize by using inputs and onChange to prevent multiple calls when clicking on the active option Debounce saving Extend binary input radio buttons to mini buttons
28ceb3a
to
96b56f2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks for making this change. It actually seems to simplify the code a bit too!
Also, optimize saving by using inputs for the buttons and utilizing onChange.
Just out of curiosity, would you mind expanding on this a little?
...props | ||
}): JSX.Element => { | ||
return ( | ||
<RadioButtonWrapper> | ||
<RadioButtonWrapper lastOptionBlue={lastOptionBlue}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this lastOptionBlue change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the designs, it looks like the mini buttons are all grey when selected, except for the last button which is blue when selected.
Since I'm extending our BinaryRadioButton component, I needed to add this to have it deviate from it's current behavior throughout the app (all selected options are blue):
Let me know if you think I should have a clearer name/add a comment in the BinaryRadioButton component describing this.
Thank you for the suggestion - it definitely simplified a lot of the code!
Absolutely! Before I just used a |
I'll merge this in as is for right now - but happy to make further adjustments in follow up PRs! |
Nice, that makes perfect sense @mxosman ! Thanks for explaining! |
return { | ||
key: metricKey, | ||
disaggregations: [ | ||
{ | ||
key: RACE_ETHNICITY_DISAGGREGATION_KEY, | ||
dimensions: updatedDimensions, | ||
dimensions, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if dimensions is undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If in line 817 raceEthnicitiesDimensions is falsey
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always a great question - part of the reason I added the raceEthnicitiesDimensions
and dimensions
below the updater function is to ensure that dimensions
will always have a value. In fact, dimensions
doesn't even really need the raceEthnicitiesDimensions &&
check.
If somehow it's undefined
and we get to this point, it'll just return the object without the dimensions
property - but I can't figure out how it could end up as undefined
by the time we get here in either function.
return { | ||
key: metricKey, | ||
disaggregations: [ | ||
{ | ||
key: RACE_ETHNICITY_DISAGGREGATION_KEY, | ||
dimensions: updatedDimensions, | ||
dimensions, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, what if dimensions is undefined?
Description of the change
Debounce saving and send all 24 dimensions instead of the deltas. Also, optimize saving by using
input
s for the buttons and utilizingonChange
.Demo: https://playtesting---justice-counts-web-qqec6jbn6a-uc.a.run.app/
Related issues
Contributes to #180
Checklists
Development
This box MUST be checked by the submitter prior to merging:
These boxes should be checked by the submitter prior to merging:
Code review
These boxes should be checked by reviewers prior to merging: