From 923a7c62193ed0208293324bebea0b895b34480d Mon Sep 17 00:00:00 2001 From: mortezaei Date: Thu, 20 Aug 2026 16:17:39 +0330 Subject: [PATCH] fix: robust option_id mapping in createQuestionField --- .../Componentes/question-answer-storage.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/Componentes/question-answer-storage.tsx b/src/components/Componentes/question-answer-storage.tsx index ec54f08..3a52c92 100644 --- a/src/components/Componentes/question-answer-storage.tsx +++ b/src/components/Componentes/question-answer-storage.tsx @@ -136,7 +136,17 @@ function createQuestionField( if (Array.isArray(value)) { option_id = value; } else if (typeof value === "string" && value) { - const selectedOpt = question.options.find((opt) => opt.id === value || opt.value === value); + const strVal = value.trim().toLowerCase(); + const selectedOpt = question.options.find( + (opt) => + opt.id === value || + opt.value === value || + opt.label === value || + opt.id.toLowerCase() === strVal || + (typeof opt.value === "string" && opt.value.toLowerCase() === strVal) || + (typeof opt.label === "string" && opt.label.toLowerCase() === strVal) || + opt.id.toLowerCase().endsWith(`.${strVal}`) + ); option_id = selectedOpt ? selectedOpt.id : value; } }