From 92d88271d7339e005e206b8809301e93da07957a Mon Sep 17 00:00:00 2001 From: Dhruwang Jariwala <67850763+Dhruwang@users.noreply.github.com> Date: Wed, 13 Mar 2024 14:41:40 +0530 Subject: [PATCH] fix: scroll to bottom when other option is selected (#2204) --- .../questions/MultipleChoiceMultiQuestion.tsx | 11 ++++++++--- .../questions/MultipleChoiceSingleQuestion.tsx | 17 ++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/packages/surveys/src/components/questions/MultipleChoiceMultiQuestion.tsx b/packages/surveys/src/components/questions/MultipleChoiceMultiQuestion.tsx index c91850b6a3..6b62b30bb6 100644 --- a/packages/surveys/src/components/questions/MultipleChoiceMultiQuestion.tsx +++ b/packages/surveys/src/components/questions/MultipleChoiceMultiQuestion.tsx @@ -77,10 +77,13 @@ export default function MultipleChoiceMultiQuestion({ ); const otherSpecify = useRef(null); + const choicesContainerRef = useRef(null); useEffect(() => { - if (otherSelected) { - otherSpecify.current?.focus(); + // Scroll to the bottom of choices container and focus on 'otherSpecify' input when 'otherSelected' is true + if (otherSelected && choicesContainerRef.current && otherSpecify.current) { + choicesContainerRef.current.scrollTop = choicesContainerRef.current.scrollHeight; + otherSpecify.current.focus(); } }, [otherSelected]); @@ -126,7 +129,9 @@ export default function MultipleChoiceMultiQuestion({
Options -
+
{questionChoices.map((choice, idx) => (