From 2a73b6460db2a5514e18ffcf48d708b5346808cb Mon Sep 17 00:00:00 2001 From: joyal007 Date: Sat, 7 Oct 2023 00:53:38 +0530 Subject: [PATCH] Added optional enter to submit event --- .../src/components/MultipleChoiceSingleQuestion.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/surveys/src/components/MultipleChoiceSingleQuestion.tsx b/packages/surveys/src/components/MultipleChoiceSingleQuestion.tsx index ba20135942..2bf0111287 100644 --- a/packages/surveys/src/components/MultipleChoiceSingleQuestion.tsx +++ b/packages/surveys/src/components/MultipleChoiceSingleQuestion.tsx @@ -77,7 +77,9 @@ export default function MultipleChoiceSingleQuestion({ onKeyDown={(e) => { if (e.key == "Enter") { onChange({ [question.id]: choice.label }); - onSubmit({ [question.id]: choice.label }); + setTimeout(() => { + onSubmit({ [question.id]: choice.label }); + }, 350); } }} className={cn( @@ -150,6 +152,11 @@ export default function MultipleChoiceSingleQuestion({ onChange={(e) => { onChange({ [question.id]: e.currentTarget.value }); }} + onKeyDown={(e) => { + if (e.key == "Enter") { + onSubmit({ [question.id]: value }); + } + }} placeholder="Please specify" className="mt-3 flex h-10 w-full rounded-md border border-slate-300 bg-transparent bg-white px-3 py-2 text-sm text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-slate-400 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-500 dark:text-slate-300" required={question.required}