Merge pull request #3689 from Tibsfox/fix/interview-notes-enter-loop
fix(tui): prevent Enter key infinite loop in interview notes mode
This commit is contained in:
commit
21898dec7e
2 changed files with 9 additions and 11 deletions
|
|
@ -300,7 +300,7 @@ export async function showInterviewRound(
|
|||
// instead of being trapped in a re-asking loop (bug #2715).
|
||||
// Only auto-open if the user hasn't already provided notes —
|
||||
// otherwise Enter from notes mode loops back here endlessly.
|
||||
if (!isMultiSelect(currentIdx) && states[currentIdx].cursorIndex === noneOrDoneIdx(currentIdx) && !states[currentIdx].notes) {
|
||||
if (!isMultiSelect(currentIdx) && states[currentIdx].cursorIndex === noneOrDoneIdx(currentIdx) && !states[currentIdx].notes && !states[currentIdx].notesVisible) {
|
||||
states[currentIdx].notesVisible = true;
|
||||
focusNotes = true;
|
||||
loadStateToEditor();
|
||||
|
|
|
|||
|
|
@ -109,25 +109,23 @@ describe("interview-ui notes loop regression (#3502)", () => {
|
|||
assert.equal(answer.selected, "None of the above");
|
||||
});
|
||||
|
||||
it("still auto-opens notes when selecting 'None of the above' with no prior notes", async () => {
|
||||
it("Enter on empty notes advances instead of re-opening (notesVisible guard)", async () => {
|
||||
// Press Down twice to "None of the above", Enter to select
|
||||
// Then immediately Enter again (empty notes) — this should re-open notes
|
||||
// because the guard only skips when notes are non-empty.
|
||||
// Type something on second open, then Enter to proceed.
|
||||
// Then immediately Enter again (empty notes) — notesVisible is already
|
||||
// true from auto-open, so the guard prevents re-opening and Enter
|
||||
// advances to review. The notes remain empty.
|
||||
const result = await runWithInputs(questions, [
|
||||
DOWN, // cursor → 1
|
||||
DOWN, // cursor → 2 (None of the above)
|
||||
ENTER, // commit → auto-opens notes
|
||||
ENTER, // empty notes → goNextOrSubmit → should re-open notes (empty guard)
|
||||
"o", "k", // type "ok"
|
||||
ENTER, // now notes = "ok" → should advance to review
|
||||
ENTER, // submit
|
||||
ENTER, // commit → auto-opens notes (notesVisible = true)
|
||||
ENTER, // empty notes → notesVisible prevents re-open → advances to review
|
||||
ENTER, // submit from review screen
|
||||
]);
|
||||
|
||||
assert.ok(result, "should return a result");
|
||||
const answer = result.answers.q1;
|
||||
assert.ok(answer, "answer for q1 should exist");
|
||||
assert.equal(answer.notes, "ok");
|
||||
assert.equal(answer.notes, "");
|
||||
});
|
||||
|
||||
it("normal option selection is unaffected", async () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue