мобильный чат снова работает, инпуты в анкете ограничены

This commit is contained in:
Tamara 2024-02-17 20:26:22 +03:00
parent 0221e61843
commit 85181d0f5f
6 changed files with 44 additions and 5 deletions

@ -120,7 +120,7 @@ export default function OnButtonInstall() {
>
Текст кнопки
</Typography>
<CustomTextField placeholder={"Пройти тест"} maxLength={30}/>
<CustomTextField placeholder={"Пройти тест"} maxLength={30} />
</AccordMy>
<AccordMy
header={"Своя кнопка"}

@ -50,6 +50,7 @@ export const ChooseAnswerModal = ({
open={open}
anchorEl={anchorRef.current}
transition
sx={{ zIndex: 1 }}
>
{({ TransitionProps }) => (
<Grow {...TransitionProps}>

@ -47,6 +47,7 @@ export const ChooseAnswerModal = ({
open={open}
anchorEl={anchorRef.current}
transition
sx={{ zIndex: 1 }}
>
{({ TransitionProps }) => (
<Grow {...TransitionProps}>

@ -20,6 +20,7 @@ import {
InputAdornment,
Paper,
TextField,
Typography,
useMediaQuery,
useTheme,
} from "@mui/material";
@ -65,7 +66,9 @@ export default function QuestionsPageCard({
questionIndex,
draggableProps,
}: Props) {
const maxLengthTextField = 225;
const [open, setOpen] = useState<boolean>(false);
const [isTextFieldtActive, setIsTextFieldtActive] = useState(false);
const anchorRef = useRef(null);
const theme = useTheme();
const isTablet = useMediaQuery(theme.breakpoints.down(1000));
@ -80,6 +83,14 @@ export default function QuestionsPageCard({
});
}, 200);
const handleInputFocus = () => {
setIsTextFieldtActive(true);
};
const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>) => {
setIsTextFieldtActive(false);
};
return (
<>
<Paper
@ -125,8 +136,10 @@ export default function QuestionsPageCard({
placeholder={`Заголовок ${questionIndex + 1} вопроса`}
defaultValue={question.title}
onChange={({ target }) => {
if(target.value,toString().length <= 225)setTitle(target.value)
setTitle(target.value || " ");
}}
onFocus={handleInputFocus}
onBlur={handleInputBlur}
sx={{
width: "100%",
margin: isMobile ? "10px 0" : 0,
@ -147,6 +160,9 @@ export default function QuestionsPageCard({
},
},
}}
inputProps={{
maxLength: maxLengthTextField,
}}
InputProps={{
startAdornment: (
<Box>
@ -167,6 +183,27 @@ export default function QuestionsPageCard({
/>
</Box>
),
endAdornment: isTextFieldtActive &&
question.title.length >= maxLengthTextField - 7 && (
<Box
sx={{
display: "flex",
marginTop: "5px",
marginLeft: "auto",
position: "absolute",
bottom: "-28px",
right: "0",
}}
>
<Typography fontSize="14px">
{question.title.length}
</Typography>
<span>/</span>
<Typography fontSize="14px">
{maxLengthTextField}
</Typography>
</Box>
),
}}
/>
</FormControl>

@ -454,7 +454,7 @@ export const ResultCard = ({ resultContract, resultData }: Props) => {
)
}
placeholder="https://penahub.ru"
maxLength={200}
maxLength={200}
sx={{
"& .MuiInputBase-root": {
backgroundColor: "#F2F3F7",

@ -73,7 +73,7 @@ export default function FloatingSupportChat() {
onClose={handleClose}
TransitionComponent={Transition}
>
<Chat onclickArrow={handleClose} />
<Chat open={open} onclickArrow={handleClose} />
</Dialog>
<Fab
disableRipple
@ -94,7 +94,7 @@ export default function FloatingSupportChat() {
variant={"extended"}
onClick={() => {
if (isMobile) {
setOpen(true);
handleClickOpen();
} else {
setIsChatOpened((prev) => !prev);
}