fix: github linting warnings (#1852)

Co-authored-by: Matti Nannt <mail@matthiasnannt.com>
This commit is contained in:
Dhruwang Jariwala
2024-01-08 18:06:20 +05:30
committed by GitHub
parent d3e0e67bd9
commit 1f79416367
4 changed files with 8 additions and 7 deletions

View File

@@ -55,7 +55,7 @@ export default function MultipleChoiceMultiQuestion({
setOtherValue(
(Array.isArray(value) && value.filter((v) => !question.choices.find((c) => c.label === v))[0]) || ""
);
}, [question.id]);
}, [question.id, getChoicesWithoutOtherLabels, question.choices, value]);
const questionChoices = useMemo(() => {
if (!question.choices) {

View File

@@ -57,8 +57,9 @@ export default function MultipleChoiceSingleQuestion({
);
useEffect(() => {
setOtherSelected(!!value && !question.choices.find((c) => c.label === value));
}, [question.id]);
const isOtherSelected = value !== undefined && !question.choices.some((choice) => choice.label === value);
setOtherSelected(isOtherSelected);
}, [question.id, question.choices, value]);
const otherSpecify = useRef<HTMLInputElement | null>(null);

View File

@@ -47,11 +47,11 @@ export default function OpenTextQuestion({
};
const openTextRef = useCallback(
(currentElement: HTMLInputElement | HTMLTextAreaElement | null) => {
if (currentElement && autoFocus) {
if (question.id && currentElement && autoFocus) {
currentElement.focus();
}
},
[question.id]
[question.id, autoFocus]
);
const isInputEmpty = (value: string) => {
return question.required && !value?.trim();

View File

@@ -27,7 +27,7 @@ export const useTtc = (
) => {
useEffect(() => {
setStartTime(performance.now());
}, [questionId]);
}, [questionId, setStartTime]);
useEffect(() => {
const handleVisibilityChange = () => {
@@ -47,5 +47,5 @@ export const useTtc = (
// Clean up the event listener when the component is unmounted
document.removeEventListener("visibilitychange", handleVisibilityChange);
};
}, []);
}, [questionId, setStartTime, setTtc, startTime, ttc]);
};