подправлена стартовая станица мобилки, автофокус на инпуте, отправка данных при быстром переходе к следующему вопросу
This commit is contained in:
parent
3b7bc5dafc
commit
19d805d4ff
@ -302,7 +302,7 @@ function QuizPreviewLayoutByType({
|
|||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
alignItems: "flex-start",
|
alignItems: "flex-start",
|
||||||
p: "25px",
|
p: "25px",
|
||||||
height: "80%",
|
height: "100%",
|
||||||
overflowY: "auto",
|
overflowY: "auto",
|
||||||
overflowX: "hidden"
|
overflowX: "hidden"
|
||||||
}}
|
}}
|
||||||
|
@ -8,7 +8,7 @@ import { sendAnswer } from "@api/quizRelase";
|
|||||||
import { useQuizData } from "@contexts/QuizDataContext";
|
import { useQuizData } from "@contexts/QuizDataContext";
|
||||||
import { useRootContainerSize } from "@contexts/RootContainerWidthContext";
|
import { useRootContainerSize } from "@contexts/RootContainerWidthContext";
|
||||||
import { enqueueSnackbar } from "notistack";
|
import { enqueueSnackbar } from "notistack";
|
||||||
import { useState } from "react";
|
import {useEffect, useState} from "react";
|
||||||
import { useDebouncedCallback } from "use-debounce";
|
import { useDebouncedCallback } from "use-debounce";
|
||||||
import type { QuizQuestionText } from "../../../model/questionTypes/text";
|
import type { QuizQuestionText } from "../../../model/questionTypes/text";
|
||||||
|
|
||||||
@ -68,6 +68,12 @@ export const Text = ({ currentQuestion, stepNumber }: TextProps) => {
|
|||||||
|
|
||||||
setIsSending(false);
|
setIsSending(false);
|
||||||
}, 400);
|
}, 400);
|
||||||
|
useEffect(
|
||||||
|
() => () => {
|
||||||
|
inputHC.flush();
|
||||||
|
},
|
||||||
|
[inputHC]
|
||||||
|
);
|
||||||
switch (spec) {
|
switch (spec) {
|
||||||
case true:
|
case true:
|
||||||
return <TextSpecial currentQuestion={currentQuestion} spec={true} answer={answer} inputHC={inputHC} stepNumber={stepNumber}/>;
|
return <TextSpecial currentQuestion={currentQuestion} spec={true} answer={answer} inputHC={inputHC} stepNumber={stepNumber}/>;
|
||||||
@ -78,7 +84,15 @@ export const Text = ({ currentQuestion, stepNumber }: TextProps) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const TextNormal = ({currentQuestion, spec, answer, inputHC}) => {
|
interface Props {
|
||||||
|
currentQuestion: QuizQuestionText;
|
||||||
|
spec: boolean | undefined;
|
||||||
|
answer: any,
|
||||||
|
stepNumber: number | null;
|
||||||
|
inputHC: (string) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TextNormal = ({currentQuestion, spec, answer, inputHC, stepNumber}: Props) => {
|
||||||
const isMobile = useRootContainerSize() < 650;
|
const isMobile = useRootContainerSize() < 650;
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
return(
|
return(
|
||||||
@ -94,6 +108,7 @@ const TextNormal = ({currentQuestion, spec, answer, inputHC}) => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CustomTextField
|
<CustomTextField
|
||||||
|
autoFocus={true}
|
||||||
placeholder={currentQuestion.content.placeholder}
|
placeholder={currentQuestion.content.placeholder}
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
value={answer || ""}
|
value={answer || ""}
|
||||||
@ -122,11 +137,10 @@ const TextNormal = ({currentQuestion, spec, answer, inputHC}) => {
|
|||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
const TextSpecial = ({currentQuestion, spec, answer, inputHC, stepNumber}) => {
|
const TextSpecial = ({currentQuestion, spec, answer, inputHC, stepNumber}: Props) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isMobile = useRootContainerSize() < 650;
|
const isMobile = useRootContainerSize() < 650;
|
||||||
const isHorizontal = Orientation[stepNumber -1].horizontal
|
const isHorizontal = Orientation[stepNumber -1].horizontal
|
||||||
console.log(stepNumber)
|
|
||||||
return(
|
return(
|
||||||
<Box sx={{display: "flex", flexDirection: isMobile? "column" : undefined, alignItems: isMobile ? "center" : undefined,}}>
|
<Box sx={{display: "flex", flexDirection: isMobile? "column" : undefined, alignItems: isMobile ? "center" : undefined,}}>
|
||||||
<Box
|
<Box
|
||||||
@ -151,6 +165,7 @@ const TextNormal = ({currentQuestion, spec, answer, inputHC}) => {
|
|||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
<TextField
|
<TextField
|
||||||
|
autoFocus={true}
|
||||||
multiline
|
multiline
|
||||||
maxRows={4}
|
maxRows={4}
|
||||||
placeholder={currentQuestion.content.placeholder}
|
placeholder={currentQuestion.content.placeholder}
|
||||||
|
Loading…
Reference in New Issue
Block a user