Added optional enter to submit event

This commit is contained in:
joyal007
2023-10-07 00:53:38 +05:30
parent 20a9b4f3c4
commit 2a73b6460d

View File

@@ -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}