-
Notifications
You must be signed in to change notification settings - Fork 1
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
Fix Scorecard demo repeat selection issue #232
Conversation
setIsTryMeDemo(true) | ||
|
||
try { | ||
const newScorecardResponseJson: ScorecardJsonResponseType = getDemoSample(demoSampleOption) | ||
setScorecardResponseJson(newScorecardResponseJson) | ||
setScorecardResponseJson({ ...newScorecardResponseJson }) |
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.
Going to assume this spread wasn't enough to make it unique/trigger a new component load?
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.
Yes, that's correct, that's why it would only work again if the results actually changed, if you ran the same sample again, it would never show up
@@ -149,11 +150,13 @@ export default function ScorecardHome() { | |||
console.log('handleSubmitDemoStart(e), event: ', e) | |||
console.log('Starting demo with sample: ' + demoSampleOption) | |||
|
|||
resetResultsData() |
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.
This is a problem. As is, if we call resetResultsData() then it sets isTryMe to false which causes a button to appear which should not, among other possible side-effects. If you think it makes sense (and I can see the validity) then we need a boolean argument to be added to resetResultsData to set isTryMe as needed.
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.
This was an attempt to get the component to reload to fix this issue, but it wasn't what resolved the issue, so I removed it. I did reset isTryMeDemo to true right after calling resetResultsData() it to prevent any issues in my previous implementation, but we don't have to worry about it at all now
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.
Oh ok, I missed that you reset it. But yeah, removing is best as that's the tested state. Thanks!
@@ -58,6 +58,7 @@ export default function ScorecardHome() { | |||
} | |||
|
|||
const [isTryMeDemo, setIsTryMeDemo] = useState(false) | |||
const [dialogKey, setDialogKey] = useState(0) |
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.
This is a perfectly fine solution. But, if it worke. something like this might be simpler as it's all contained in one place/requires no new state?
if (isValidResults) {
setResultsDialogState(false); // Reset the state
setTimeout(() => setResultsDialogState(true), 0); // Trigger the dialog
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.
That worked fine, so I removed the state I added
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.
Cool!
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.
Thanks for looking into this!
The comment about resetResultsData needs to be reviewed (the diff) and addressed
No description provided.