Skip to content
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

Merged
merged 4 commits into from
Nov 26, 2024

Conversation

ebrockainq
Copy link
Contributor

No description provided.

@drbgfc drbgfc changed the title Fix scorecard Try Me not able to be used twice Fix Scorecard demo repeat selection issue Nov 25, 2024
setIsTryMeDemo(true)

try {
const newScorecardResponseJson: ScorecardJsonResponseType = getDemoSample(demoSampleOption)
setScorecardResponseJson(newScorecardResponseJson)
setScorecardResponseJson({ ...newScorecardResponseJson })
Copy link
Contributor

@drbgfc drbgfc Nov 25, 2024

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?

Copy link
Contributor Author

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()
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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)
Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

Copy link
Contributor

@drbgfc drbgfc left a 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

@drbgfc drbgfc merged commit 16c707a into dev Nov 26, 2024
3 checks passed
@drbgfc drbgfc deleted the Evan-fix-scorecard-tryme-not-reuseable branch November 26, 2024 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants