Issues with multiple dialog boxes using showDialog
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- react, typescript
- Domain
- frontend
Research direction
Start in src/ui/views/RunEditor.tsx at importComparison and trace the showDialog entry point used by the two sequential calls. Reproduce the flow with the two dialogs, then inspect how each dialog resolves and closes. Done means the second dialog reports its own result only after it is closed, without requiring setTimeout, while the import flow still completes correctly.
Written by the indexing model from the issue text.
Description
I was doing some work with importing comparisons other than the Personal Best comparison (LiveSplit/livesplit-core#889) and came across an issue when attempting to display multiple dialog boxes with showDialog right after each other.
In src/ui/views/RunEditor.tsx, I attempted to add another dialog box to the importComparison function like so:
const [dialogResult, runComparisonName] = await showDialog({
title: "Import Comparison",
description: "Specify the name of the comparison you want to import:",
textInput: true,
buttons: ["Ok", "Cancel"],
defaultText: file.name.replace(/\.[^/.]+$/, ""),
});
if (dialogResult !== 0) {
return;
}
const [dialogResult2, comparisonName] = await showDialog({
title: "Import Comparison",
description: "Specify the name the comparison should be saved as:",
textInput: true,
buttons: ["Import", "Cancel"],
defaultText: file.name.replace(/\.[^/.]+$/, ""),
});
if (dialogResult2 !== 0) {
return;
}
After doing this, I noticed that—while both dialog boxes would appear one after the other as expected—the second dialog box would handle its result before it was closed. That is, dialogResult2 would have the value true and hit the if (dialogResult2 !== 0) { line as soon as the first dialog box was completed.
Out of curiosity about it being a possible race condition, I added setTimeout around the second dialog box (and all subsequent code) and found that it would work perfectly fine as expected. See the code below:
const [dialogResult, runComparisonName] = await showDialog({
title: "Import Comparison",
description: "Specify the name of the comparison you want to import:",
textInput: true,
buttons: ["Ok", "Cancel"],
defaultText: file.name.replace(/\.[^/.]+$/, ""),
});
if (dialogResult !== 0) {
return;
}
setTimeout(async () => {
const [dialogResult2, comparisonName] = await showDialog({
title: "Import Comparison",
description: "Specify the name the comparison should be saved as:",
textInput: true,
buttons: ["Import", "Cancel"],
defaultText: file.name.replace(/\.[^/.]+$/, ""),
});
console.log(dialogResult2);
if (dialogResult2 !== 0) {
return;
}
const valid = editor.importComparisonAsComparison(run, comparisonName, runComparisonName);
if (!valid) {
toast.error(
"The comparison could not be added. It may be a duplicate or a reserved name.",
);
} else {
update();
}
}, 0)
I couldn't make anything of the showDialog function when trying to identify the issue, so unfortunately could not continue without adding setTimeout, which should not be the fix I go with for what I'm trying to do.
- Dominant language
- TypeScript
- Stars
- 301
- Forks
- 55
- Avg merge
- 8m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from LiveSplit/LiveSplitOne
-
Difficulty 3/5 1-2 days Newbie friendliness 62/100
LiveSplit/LiveSplitOne#1162 ·
-
enhancement suitable for contributions UI
Difficulty 5/5 Over a week Newbie friendliness 35/100
LiveSplit/LiveSplitOne#1139 ·
-
enhancement suitable for contributions UI
Difficulty 4/5 3-5 days Newbie friendliness 45/100
LiveSplit/LiveSplitOne#1138 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 58/100
LiveSplit/LiveSplitOne#1129 · 12 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
LiveSplit/LiveSplitOne#1121 ·
All issues in LiveSplit/LiveSplitOne
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
safetrustcr/dApp-SafeTrust#426 ·
-
area:workflow bug ready-for-agent
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
fil-donadoni/tolaria#4409 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Fission-AI/OpenSpec#1960 ·
-
Add dependabot Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
corsairdev/corsair#1764 ·