authorgravatar for 150583432+RaitP1@users.noreply.github.comRaitP1 <150583432+RaitP1@users.noreply.github.com> 2026-08-15 15:25:57+03:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-08-15 12:25:57+00:00
log1a5ff424cee104e1e8bbcf9bbf5414bbad843be3
treeab7c7a44b26ba976b6b64b02e8aeea8f43ae6589
parentb72d5d79889ad9b4c022060be9eccdfa64733d18
signature Signed by PGP key B5690EEEBB952194

fix(web): keep multi-select questions open after the first click (#6646)


1 files changed, 19 insertions(+), 16 deletions(-)

apps/web/src/components/chat/ComposerPendingUserInputPanel.tsx+19-16
......@@ -1,5 +1,5 @@
11import { type ApprovalRequestId } from "@t3tools/contracts";
2import { memo, useEffect, useEffectEvent, useRef, useState } from "react";
2import { memo, useCallback, useEffect, useRef, useState } from "react";
33import { type PendingUserInput } from "../../session-logic";
44import {
55 derivePendingUserInputProgress,
......@@ -109,21 +109,24 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
109109 };
110110 }, []);
111111
112 const handleOptionSelection = useEffectEvent((questionId: string, optionLabel: string) => {
113 if (activeQuestion?.multiSelect) {
112 const handleOptionSelection = useCallback(
113 (questionId: string, optionLabel: string) => {
114 if (activeQuestion?.multiSelect) {
115 onToggleOption(questionId, optionLabel);
116 return;
117 }
118 setOptimisticSingleSelect({ questionId, optionLabel });
114119 onToggleOption(questionId, optionLabel);
115 return;
116 }
117 setOptimisticSingleSelect({ questionId, optionLabel });
118 onToggleOption(questionId, optionLabel);
119 if (autoAdvanceTimerRef.current !== null) {
120 window.clearTimeout(autoAdvanceTimerRef.current);
121 }
122 autoAdvanceTimerRef.current = window.setTimeout(() => {
123 autoAdvanceTimerRef.current = null;
124 onAdvanceRef.current();
125 }, 200);
126 });
120 if (autoAdvanceTimerRef.current !== null) {
121 window.clearTimeout(autoAdvanceTimerRef.current);
122 }
123 autoAdvanceTimerRef.current = window.setTimeout(() => {
124 autoAdvanceTimerRef.current = null;
125 onAdvanceRef.current();
126 }, 200);
127 },
128 [activeQuestion, onToggleOption],
129 );
127130
128131 // Keyboard shortcut: number keys 1-9 select corresponding options when focus is
129132 // outside editable fields. Multi-select prompts toggle options in place; single-
......@@ -154,7 +157,7 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
154157 };
155158 document.addEventListener("keydown", handler);
156159 return () => document.removeEventListener("keydown", handler);
157 }, [activeQuestion, isCollapsed, isResponding]);
160 }, [activeQuestion, handleOptionSelection, isCollapsed, isResponding]);
158161
159162 if (!activeQuestion) {
160163 return null;