Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(FEC-14262): Player v7 | Quiz | Wrong first element focus on quiz questions overlay. #145

Merged
merged 5 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/quiz-question/multi-choice/multi-choice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const MultiChoice = withText(translates)(

useEffect(() => {
if (!disabled) {
quizQuestionRef.current?.focus();
answersOptionsRefMap.get(0)?.focus();
}
}, [question]);

Expand Down
4 changes: 3 additions & 1 deletion src/components/quiz-question/open-question/open-question.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const translates = (): QuizTranslates => {
export const OpenQuestion = withText(translates)(
({question, selected, onSelect, hint, questionIndex, ...otherProps}: QuestionProps & QuizTranslates) => {
const disabled = !onSelect;
const textareaRef = useRef<HTMLTextAreaElement>(null);

const handleChange = useCallback(
(e: any) => {
Expand All @@ -30,7 +31,7 @@ export const OpenQuestion = withText(translates)(
const quizQuestionRef = useRef<HTMLLegendElement>(null);
useEffect(() => {
if (!disabled) {
quizQuestionRef.current?.focus();
textareaRef.current?.focus();
semarche-kaltura marked this conversation as resolved.
Show resolved Hide resolved
}
}, [question]);

Expand All @@ -52,6 +53,7 @@ export const OpenQuestion = withText(translates)(
onChange={handleChange}
disabled={disabled}
data-testid="openQuestionAnswerInput"
ref={textareaRef}
/>
<div className={styles.charCounter}>{`${selected.length}/${MAX_LENGTH}`}</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/quiz-question/quiz-question-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const QuizQuestionWrapper = withText(translates)((props: QuizQuestionWrap
case KalturaQuizQuestionTypes.MultiChoice:
return <MultiChoice {...questionProps} />;
case KalturaQuizQuestionTypes.Reflection:
return <ReflectionPoint {...questionProps} />;
return <ReflectionPoint {...questionProps} continueButton={continueButtonRef}/>;
Tzipi-kaltura marked this conversation as resolved.
Show resolved Hide resolved
case KalturaQuizQuestionTypes.OpenQuestion:
return <OpenQuestion {...questionProps} />;
case KalturaQuizQuestionTypes.MultiAnswer:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import {h} from 'preact';
import {h, RefObject} from 'preact';
import {useEffect, useRef} from 'preact/hooks';
import {QuestionProps, QuizTranslates} from '../../../types';
import * as styles from './reflection-point.scss';
import {wrapLinksWithTags} from '../../../utils';

const {withText, Text} = KalturaPlayer.ui.preacti18n;

interface reflectionPointProps {
continueButton: RefObject<HTMLDivElement>;
}
Tzipi-kaltura marked this conversation as resolved.
Show resolved Hide resolved

const translates = (): QuizTranslates => {
return {
reflectionPoint: <Text id="ivq.reflection_point">Reflection Point</Text>,
questionLabel: <Text id="ivq.question">Question</Text>
};
};

export const ReflectionPoint = withText(translates)(({question, questionIndex, ...otherProps}: QuestionProps & QuizTranslates) => {
export const ReflectionPoint = withText(translates)(({question, questionIndex, ...otherProps}: QuestionProps & QuizTranslates & reflectionPointProps) => {
const quizQuestionRef = useRef<HTMLLegendElement>(null);
useEffect(() => {
quizQuestionRef.current?.focus();
otherProps.continueButton.current?.focus();
}, [question]);

return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/quiz-question/true-false/true-false.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const TrueFalse = withText(translates)(
const quizQuestionRef = useRef<HTMLLegendElement>(null);
useEffect(() => {
if (!disabled) {
quizQuestionRef.current?.focus();
answersOptionsRefMap.get(0)?.focus();
}
}, [question]);

Expand Down
Loading