обавлена кнопка 'Done' на клавиатуре iOS для сворачивания клавиатуры при вводе названия стикерпака
This commit is contained in:
parent
05a4363d91
commit
4049792297
@ -1,4 +1,4 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect, useRef } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import styles from './CreateStickerPack.module.css';
|
import styles from './CreateStickerPack.module.css';
|
||||||
import { stickerService } from '../services/stickerService';
|
import { stickerService } from '../services/stickerService';
|
||||||
@ -55,6 +55,22 @@ const CreateStickerPack: React.FC = () => {
|
|||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [creating, setCreating] = useState(false);
|
const [creating, setCreating] = useState(false);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
const titleInputRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
|
// Функция для сворачивания клавиатуры
|
||||||
|
const dismissKeyboard = () => {
|
||||||
|
if (titleInputRef.current) {
|
||||||
|
titleInputRef.current.blur();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Обработчик нажатия клавиш для поля ввода названия
|
||||||
|
const handleTitleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
||||||
|
if (e.key === 'Enter') {
|
||||||
|
e.preventDefault();
|
||||||
|
dismissKeyboard();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Загрузка доступных изображений
|
// Загрузка доступных изображений
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -176,6 +192,9 @@ const CreateStickerPack: React.FC = () => {
|
|||||||
value={title}
|
value={title}
|
||||||
onChange={(e) => setTitle(e.target.value)}
|
onChange={(e) => setTitle(e.target.value)}
|
||||||
placeholder="Введите название стикерпака"
|
placeholder="Введите название стикерпака"
|
||||||
|
ref={titleInputRef}
|
||||||
|
onKeyDown={handleTitleKeyDown}
|
||||||
|
enterKeyHint="done"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user