Conversation
Users can type < at any prompt to re-answer the previous question. A contextual hint is shown from the second question onward. Conditional questions respond correctly when a gating answer changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
<at any prompt to re-answer the previous questiontype < to go back) is shown from the second question onward; no hint on the first questionImplementation
Form.unrecord(key)— removes an answer fromform.answersandform._user_answersForm.set_question_index(n)— sets the question index directly (used by the iterative loop)_GoBackRequest(Exception)— sentinel raised by_ask_*methods; caught by_ask_questionsBaseRenderer._BACK_COMMAND = "<"— the back command string (override to change it)BaseRenderer._back_hint()— returns a hint string when going back is available, empty string otherwiseBaseRenderer._iter_active_leaves()— recomputes active visible leaf questions dynamically each iterationBaseRenderer._ask_questions()— refactored from recursive to iterative with ahistory: list[str]stackAll three interactive renderers (
StdlibRenderer,RichRenderer,CookiecutterRenderer) implement the pattern.NoInputRendereris unaffected.Documentation
docs/src/reference/base-renderer.md— new "Back navigation" section documenting_GoBackRequest,_BACK_COMMAND,_back_hint(), and the implementation contractdocs/src/how-to-guides/create-renderer.md— example renderer updated to support back navigation; new "Support back navigation" section addeddocs/src/tutorials/your-first-form.md— user-facing mention of the<commandTest plan
test_back_on_second_question_rerenders_first— basic back navigationtest_back_on_first_question_stays_at_first— no-op on first questiontest_back_multiple_times— multiple back stepstest_back_from_boolean/choice/multiple_rerenders_previous_string— back across question typestest_back_past_gating_question_hides_conditional— conditional question hidden after back + re-selecttest_back_past_gating_question_shows_conditional_on_reselect— conditional question shown after back + re-selecttest_back_hint_not_shown_for_first_question/test_back_hint_shown_for_second_questionCloses #10