From 05a4363d91375780ddf3e0a4a049d3d9e2ef8e49 Mon Sep 17 00:00:00 2001 From: kazachilo Date: Mon, 17 Mar 2025 14:59:56 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B0=20'Done'=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=BA=D0=BB=D0=B0=D0=B2=D0=B8=D0=B0=D1=82=D1=83=D1=80?= =?UTF-8?q?=D0=B5=20iOS=20=D0=B4=D0=BB=D1=8F=20=D1=81=D0=B2=D0=BE=D1=80?= =?UTF-8?q?=D0=B0=D1=87=D0=B8=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=BA=D0=BB?= =?UTF-8?q?=D0=B0=D0=B2=D0=B8=D0=B0=D1=82=D1=83=D1=80=D1=8B=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=20=D0=B2=D0=B2=D0=BE=D0=B4=D0=B5=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=BC=D0=BF=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/blocks/TextInputBlock.tsx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/components/blocks/TextInputBlock.tsx b/src/components/blocks/TextInputBlock.tsx index 25d0fc4..45028bf 100644 --- a/src/components/blocks/TextInputBlock.tsx +++ b/src/components/blocks/TextInputBlock.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useState, useRef } from 'react'; import styles from './TextInputBlock.module.css'; import { TextInputBlock as TextInputBlockType } from '../../types/blocks'; @@ -11,6 +11,7 @@ interface TextInputBlockProps { // eslint-disable-next-line @typescript-eslint/no-unused-vars const TextInputBlock: React.FC = ({ block, visible, onTextChange }) => { const [text, setText] = useState(''); + const textareaRef = useRef(null); const handleChange = (e: React.ChangeEvent) => { const newText = e.target.value; @@ -18,14 +19,33 @@ const TextInputBlock: React.FC = ({ block, visible, onTextC onTextChange?.(newText); }; + // Функция для сворачивания клавиатуры + const dismissKeyboard = () => { + if (textareaRef.current) { + textareaRef.current.blur(); + } + }; + + // Обработчик нажатия клавиш + const handleKeyDown = (e: React.KeyboardEvent) => { + // Если нажата клавиша Enter (или Done на iOS) + if (e.key === 'Enter' && !e.shiftKey) { + e.preventDefault(); // Предотвращаем добавление новой строки + dismissKeyboard(); // Сворачиваем клавиатуру + } + }; + return (