+
+
{!isFirstQuestion && (
{
onBack();
}}
/>
)}
-
-
);
diff --git a/packages/surveys/src/components/questions/MatrixQuestion.tsx b/packages/surveys/src/components/questions/MatrixQuestion.tsx
index b51b0bb3c3..10e5b9fc36 100644
--- a/packages/surveys/src/components/questions/MatrixQuestion.tsx
+++ b/packages/surveys/src/components/questions/MatrixQuestion.tsx
@@ -42,7 +42,7 @@ export const MatrixQuestion = ({
const [startTime, setStartTime] = useState(performance.now());
const isMediaAvailable = question.imageUrl || question.videoUrl;
useTtc(question.id, ttc, setTtc, startTime, setStartTime, question.id === currentQuestionId);
-
+ const isCurrent = question.id === currentQuestionId;
const rowShuffleIdx = useMemo(() => {
if (question.shuffleOption) {
return getShuffledRowIndices(question.rows.length, question.shuffleOption);
@@ -149,7 +149,7 @@ export const MatrixQuestion = ({
{question.columns.map((column, columnIndex) => (
handleSelect(
@@ -195,21 +195,20 @@ export const MatrixQuestion = ({
-
- {!isFirstQuestion && (
-
- )}
-
+
{}}
- tabIndex={0}
+ tabIndex={isCurrent ? 0 : -1}
/>
+ {!isFirstQuestion && (
+
+ )}
);
diff --git a/packages/surveys/src/components/questions/MultipleChoiceMultiQuestion.tsx b/packages/surveys/src/components/questions/MultipleChoiceMultiQuestion.tsx
index 5a84f33339..1ac3b24e09 100644
--- a/packages/surveys/src/components/questions/MultipleChoiceMultiQuestion.tsx
+++ b/packages/surveys/src/components/questions/MultipleChoiceMultiQuestion.tsx
@@ -43,7 +43,7 @@ export const MultipleChoiceMultiQuestion = ({
const [startTime, setStartTime] = useState(performance.now());
const isMediaAvailable = question.imageUrl || question.videoUrl;
useTtc(question.id, ttc, setTtc, startTime, setStartTime, question.id === currentQuestionId);
-
+ const isCurrent = question.id === currentQuestionId;
const shuffledChoicesIds = useMemo(() => {
if (question.shuffleOption) {
return getShuffledChoicesIds(question.choices, question.shuffleOption);
@@ -165,7 +165,7 @@ export const MultipleChoiceMultiQuestion = ({
return (
-
+
+
{!isFirstQuestion && (
{
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
@@ -294,12 +299,6 @@ export const MultipleChoiceMultiQuestion = ({
}}
/>
)}
-
-
);
diff --git a/packages/surveys/src/components/questions/MultipleChoiceSingleQuestion.tsx b/packages/surveys/src/components/questions/MultipleChoiceSingleQuestion.tsx
index dbaf265097..41702b4707 100644
--- a/packages/surveys/src/components/questions/MultipleChoiceSingleQuestion.tsx
+++ b/packages/surveys/src/components/questions/MultipleChoiceSingleQuestion.tsx
@@ -45,7 +45,7 @@ export const MultipleChoiceSingleQuestion = ({
const otherSpecify = useRef (null);
const choicesContainerRef = useRef(null);
const isMediaAvailable = question.imageUrl || question.videoUrl;
-
+ const isCurrent = question.id === currentQuestionId;
const shuffledChoicesIds = useMemo(() => {
if (question.shuffleOption) {
return getShuffledChoicesIds(question.choices, question.shuffleOption);
@@ -132,8 +132,8 @@ export const MultipleChoiceSingleQuestion = ({
return (
-
+
+
{!isFirstQuestion && (
{
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
setTtc(updatedTtcObj);
@@ -252,12 +256,6 @@ export const MultipleChoiceSingleQuestion = ({
}}
/>
)}
-
-
);
diff --git a/packages/surveys/src/components/questions/NPSQuestion.tsx b/packages/surveys/src/components/questions/NPSQuestion.tsx
index d2d2b2696b..c9b865694d 100644
--- a/packages/surveys/src/components/questions/NPSQuestion.tsx
+++ b/packages/surveys/src/components/questions/NPSQuestion.tsx
@@ -42,7 +42,7 @@ export const NPSQuestion = ({
const [startTime, setStartTime] = useState(performance.now());
const [hoveredNumber, setHoveredNumber] = useState(-1);
const isMediaAvailable = question.imageUrl || question.videoUrl;
-
+ const isCurrent = question.id === currentQuestionId;
useTtc(question.id, ttc, setTtc, startTime, setStartTime, question.id === currentQuestionId);
const handleClick = (number: number) => {
@@ -92,7 +92,7 @@ export const NPSQuestion = ({
return (
@@ -141,10 +142,17 @@ export const NPSQuestion = ({
-
+
+ {!question.required && (
+
+ )}
{!isFirstQuestion && (
{
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
@@ -153,14 +161,6 @@ export const NPSQuestion = ({
}}
/>
)}
-
- {!question.required && (
-
- )}
);
diff --git a/packages/surveys/src/components/questions/OpenTextQuestion.tsx b/packages/surveys/src/components/questions/OpenTextQuestion.tsx
index 9f729ea954..1c4b9b8609 100644
--- a/packages/surveys/src/components/questions/OpenTextQuestion.tsx
+++ b/packages/surveys/src/components/questions/OpenTextQuestion.tsx
@@ -44,7 +44,7 @@ export const OpenTextQuestion = ({
}: OpenTextQuestionProps) => {
const [startTime, setStartTime] = useState(performance.now());
const isMediaAvailable = question.imageUrl || question.videoUrl;
-
+ const isCurrent = question.id === currentQuestionId;
useTtc(question.id, ttc, setTtc, startTime, setStartTime, question.id === currentQuestionId);
const handleInputChange = (inputValue: string) => {
@@ -96,7 +96,7 @@ export const OpenTextQuestion = ({
{question.longAnswer === false ? (
handleInputChange(e.currentTarget.value)}
- autoFocus={autoFocusEnabled}
className="fb-border-border placeholder:fb-text-placeholder fb-text-subheading focus:fb-border-brand fb-bg-input-bg fb-rounded-custom fb-block fb-w-full fb-border fb-p-2 fb-shadow-sm focus:fb-outline-none focus:fb-ring-0 sm:fb-text-sm"
pattern={question.inputType === "phone" ? "[0-9+ ]+" : ".*"}
title={question.inputType === "phone" ? "Enter a valid phone number" : undefined}
@@ -116,7 +115,7 @@ export const OpenTextQuestion = ({
ref={openTextRef}
rows={3}
name={question.id}
- tabIndex={1}
+ tabIndex={isCurrent ? 0 : -1}
aria-label="textarea"
id={question.id}
placeholder={getLocalizedValue(question.placeholder, languageCode)}
@@ -128,7 +127,6 @@ export const OpenTextQuestion = ({
handleInputChange(e.currentTarget.value);
handleInputResize(e);
}}
- autoFocus={autoFocusEnabled}
className="fb-border-border placeholder:fb-text-placeholder fb-bg-input-bg fb-text-subheading focus:fb-border-brand fb-rounded-custom fb-block fb-w-full fb-border fb-p-2 fb-shadow-sm focus:fb-ring-0 sm:fb-text-sm"
pattern={question.inputType === "phone" ? "[+][0-9 ]+" : ".*"}
title={question.inputType === "phone" ? "Please enter a valid phone number" : undefined}
@@ -137,9 +135,16 @@ export const OpenTextQuestion = ({
-
+
+ {}}
+ />
{!isFirstQuestion && (
{
const updatedttc = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
@@ -148,12 +153,6 @@ export const OpenTextQuestion = ({
}}
/>
)}
-
- {}}
- />
);
diff --git a/packages/surveys/src/components/questions/PictureSelectionQuestion.tsx b/packages/surveys/src/components/questions/PictureSelectionQuestion.tsx
index b7b83b0d98..98b6bc72f7 100644
--- a/packages/surveys/src/components/questions/PictureSelectionQuestion.tsx
+++ b/packages/surveys/src/components/questions/PictureSelectionQuestion.tsx
@@ -41,8 +41,8 @@ export const PictureSelectionQuestion = ({
}: PictureSelectionProps) => {
const [startTime, setStartTime] = useState(performance.now());
const isMediaAvailable = question.imageUrl || question.videoUrl;
-
- useTtc(question.id, ttc, setTtc, startTime, setStartTime, question.id === currentQuestionId);
+ const isCurrent = question.id === currentQuestionId;
+ useTtc(question.id, ttc, setTtc, startTime, setStartTime, isCurrent);
const addItem = (item: string) => {
let values: string[] = [];
@@ -111,10 +111,10 @@ export const PictureSelectionQuestion = ({
-
+
+
{!isFirstQuestion && (
{
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
@@ -208,12 +213,6 @@ export const PictureSelectionQuestion = ({
}}
/>
)}
-
-
);
diff --git a/packages/surveys/src/components/questions/RankingQuestion.tsx b/packages/surveys/src/components/questions/RankingQuestion.tsx
index 634c4ac495..35f101e337 100644
--- a/packages/surveys/src/components/questions/RankingQuestion.tsx
+++ b/packages/surveys/src/components/questions/RankingQuestion.tsx
@@ -42,7 +42,7 @@ export const RankingQuestion = ({
currentQuestionId,
}: RankingQuestionProps) => {
const [startTime, setStartTime] = useState(performance.now());
-
+ const isCurrent = question.id === currentQuestionId;
const shuffledChoicesIds = useMemo(() => {
if (question.shuffleOption) {
return getShuffledChoicesIds(question.choices, question.shuffleOption);
@@ -148,7 +148,12 @@ export const RankingQuestion = ({
return (
{
+ if (e.key === " ") {
+ handleItemClick(item);
+ }
+ }}
className={cn(
"fb-flex fb-h-12 fb-items-center fb-mb-2 fb-border fb-border-border fb-transition-all fb-text-heading focus-within:fb-border-brand hover:fb-bg-input-bg-selected focus:fb-bg-input-bg-selected fb-rounded-custom fb-relative fb-cursor-pointer focus:fb-outline-none fb-transform fb-duration-500 fb-ease-in-out",
isSorted ? "fb-bg-input-bg-selected" : "fb-bg-input-bg"
@@ -173,6 +178,7 @@ export const RankingQuestion = ({
{isSorted && (
-
+
+
{!isFirstQuestion && (
{
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
setTtc(updatedTtcObj);
@@ -244,12 +256,6 @@ export const RankingQuestion = ({
}}
/>
)}
-
-
);
diff --git a/packages/surveys/src/components/questions/RatingQuestion.tsx b/packages/surveys/src/components/questions/RatingQuestion.tsx
index 87d9481c7d..353b4ade53 100644
--- a/packages/surveys/src/components/questions/RatingQuestion.tsx
+++ b/packages/surveys/src/components/questions/RatingQuestion.tsx
@@ -54,7 +54,7 @@ export const RatingQuestion = ({
const [hoveredNumber, setHoveredNumber] = useState(0);
const [startTime, setStartTime] = useState(performance.now());
const isMediaAvailable = question.imageUrl || question.videoUrl;
-
+ const isCurrent = question.id === currentQuestionId;
useTtc(question.id, ttc, setTtc, startTime, setStartTime, question.id === currentQuestionId);
const handleSelect = (number: number) => {
@@ -138,7 +138,7 @@ export const RatingQuestion = ({
className="fb-bg-survey-bg fb-flex-1 fb-text-center fb-text-sm">
{question.scale === "number" ? (
) : question.scale === "star" ? (
) : (
-
+
+ {!question.required && (
+
+ )}
+
{!isFirstQuestion && (
{
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
@@ -252,14 +260,6 @@ export const RatingQuestion = ({
}}
/>
)}
-
- {!question.required && (
-
- )}
);
|