@@ -92,8 +92,9 @@ const CARD_LAYOUT_TRANSITION = LinearTransition.duration(200);
9292export function PendingUserInputCard ( props : PendingUserInputCardProps ) {
9393 const questionCount = props . pendingUserInput . questions . length ;
9494 const [ previewSelection , setPreviewSelection ] = useState < {
95+ requestId : ApprovalRequestId ;
9596 questionId : string ;
96- optionValue : string ;
97+ optionIndex : number ;
9798 } | null > ( null ) ;
9899
99100 const cardCoverage = props . cardCoverage ;
@@ -263,13 +264,11 @@ export function PendingUserInputCard(props: PendingUserInputCardProps) {
263264 >
264265 { props . pendingUserInput . questions . map ( ( question ) => {
265266 const draft = props . drafts [ question . id ] ;
266- const selectedOption = question . options . find ( ( option ) => {
267- const optionValue = option . value ?? option . label . trim ( ) ;
268- return (
269- previewSelection ?. questionId === question . id &&
270- previewSelection . optionValue === optionValue
271- ) ;
272- } ) ;
267+ const selectedOption =
268+ previewSelection ?. requestId === props . pendingUserInput . requestId &&
269+ previewSelection . questionId === question . id
270+ ? question . options [ previewSelection . optionIndex ]
271+ : undefined ;
273272 const previewOption =
274273 selectedOption ?. preview ?. trim ( ) ? selectedOption : undefined ;
275274 const previewText = previewOption ?. preview ?. trim ( ) ? previewOption . preview : null ;
@@ -282,7 +281,7 @@ export function PendingUserInputCard(props: PendingUserInputCardProps) {
282281 { question . question }
283282 </ Text >
284283 < View className = "gap-2" >
285- { question . options . map ( ( option ) => {
284+ { question . options . map ( ( option , optionIndex ) => {
286285 const optionValue = option . value ?? option . label . trim ( ) ;
287286 const selected = isPendingUserInputOptionSelected ( question , draft , optionValue ) ;
288287 const description =
@@ -295,7 +294,11 @@ export function PendingUserInputCard(props: PendingUserInputCardProps) {
295294 selected ? "border-primary bg-primary/10" : "border-border bg-input" ,
296295 ) }
297296 onPress = { ( ) => {
298- setPreviewSelection ( { questionId : question . id , optionValue } ) ;
297+ setPreviewSelection ( {
298+ requestId : props . pendingUserInput . requestId ,
299+ questionId : question . id ,
300+ optionIndex,
301+ } ) ;
299302 props . onSelectOption (
300303 props . pendingUserInput . requestId ,
301304 question ,
0 commit comments