Skip to content

fix: auto-save custom answer before switching question tabs#12537

Open
maharshi365 wants to merge 6 commits intoanomalyco:devfrom
maharshi365:fix/question-tab-custom-answer-leak
Open

fix: auto-save custom answer before switching question tabs#12537
maharshi365 wants to merge 6 commits intoanomalyco:devfrom
maharshi365:fix/question-tab-custom-answer-leak

Conversation

@maharshi365
Copy link
Copy Markdown
Contributor

Fixes #12536
Fixes #8199

Problem

When using the Question tool with multiple questions and custom answer options, typed text from one question's custom answer field appears in the next question when switching tabs without confirming (pressing Enter).

Reproduction Steps

  1. Trigger a question tool with multiple questions
  2. Select "Type your own answer" on Question 1
  3. Type some text (don't press Enter)
  4. Switch to Question 2 using Tab or arrow keys
  5. Select "Type your own answer" on Question 2
  6. The text from Question 1 appears in Question 2's textarea

Solution

Auto-save any uncommitted custom answer text to the current question's state before switching tabs.

Changes in selectTab():

  • Check if user is currently editing (store.editing is true)
  • Capture the raw textarea content
  • Save to store.custom[prevTab]
  • Update store.answers with the custom value
  • Reset editing state before switching to new tab

This prevents text from "leaking" to the next question and ensures answers don't disappear on the Confirm screen.

Testing

  • Verified typecheck passes for opencode package
  • Tested with both keyboard (Tab/arrow keys) and mouse tab switching
  • Works for both single-select and multi-select modes

Fixes anomalyco#12536
Fixes anomalyco#8199

When a user types a custom answer in the Question tool and switches tabs without confirming (pressing Enter), the typed text appears in the next question's textarea. This auto-saves the custom answer to the current question's state before switching tabs.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 6, 2026

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@maharshi365 maharshi365 marked this pull request as draft February 12, 2026 16:04
@maharshi365 maharshi365 reopened this Feb 12, 2026
Replaced saveCustomAnswer() with saveCustomAnswerMulti() helper and inlined
single-select logic to clarify code paths and eliminate duplication.
@maharshi365 maharshi365 marked this pull request as ready for review February 12, 2026 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant