mirror of
https://github.com/aljazceru/rabbit.git
synced 2025-12-18 14:34:25 +01:00
feat: autofocus textarea on iOS
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { createSignal, createMemo, onMount, Show, For, type Component, type JSX } from 'solid-js';
|
import { createSignal, createMemo, Show, For, type Component, type JSX } from 'solid-js';
|
||||||
|
|
||||||
import { createMutation } from '@tanstack/solid-query';
|
import { createMutation } from '@tanstack/solid-query';
|
||||||
import ExclamationTriangle from 'heroicons/24/outline/exclamation-triangle.svg';
|
import ExclamationTriangle from 'heroicons/24/outline/exclamation-triangle.svg';
|
||||||
@@ -344,13 +344,6 @@ const NotePostForm: Component<NotePostFormProps> = (props) => {
|
|||||||
onEmojiSelect: handleEmojiSelect,
|
onEmojiSelect: handleEmojiSelect,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
onMount(() => {
|
|
||||||
setTimeout(() => {
|
|
||||||
textAreaRef?.click();
|
|
||||||
textAreaRef?.focus();
|
|
||||||
}, 50);
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="p-1">
|
<div class="p-1">
|
||||||
<Show when={props.replyTo != null}>
|
<Show when={props.replyTo != null}>
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ const SideBar: Component = () => {
|
|||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
if (formOpened() && textAreaRef != null) {
|
if (formOpened() && textAreaRef != null) {
|
||||||
setTimeout(() => focusTextArea(), 100);
|
focusTextArea();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -23,13 +23,20 @@ export type TextNoteProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const TextNote: Component<TextNoteProps> = (props) => {
|
const TextNote: Component<TextNoteProps> = (props) => {
|
||||||
|
let textAreaRef: HTMLTextAreaElement | undefined;
|
||||||
|
|
||||||
const i18n = useTranslation();
|
const i18n = useTranslation();
|
||||||
const { showProfile } = useModalState();
|
const { showProfile } = useModalState();
|
||||||
const timelineContext = useTimelineContext();
|
const timelineContext = useTimelineContext();
|
||||||
|
|
||||||
const [showReplyForm, setShowReplyForm] = createSignal(false);
|
const [showReplyForm, setShowReplyForm] = createSignal(false);
|
||||||
const closeReplyForm = () => setShowReplyForm(false);
|
const closeReplyForm = () => setShowReplyForm(false);
|
||||||
const toggleReplyForm = () => setShowReplyForm((current) => !current);
|
const toggleReplyForm = () => {
|
||||||
|
setShowReplyForm((current) => !current);
|
||||||
|
if (showReplyForm() && textAreaRef != null) {
|
||||||
|
textAreaRef.focus();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const event = createMemo(() => textNote(props.event));
|
const event = createMemo(() => textNote(props.event));
|
||||||
|
|
||||||
@@ -113,6 +120,9 @@ const TextNote: Component<TextNoteProps> = (props) => {
|
|||||||
footer={
|
footer={
|
||||||
<Show when={showReplyForm()}>
|
<Show when={showReplyForm()}>
|
||||||
<NotePostForm
|
<NotePostForm
|
||||||
|
textAreaRef={(el) => {
|
||||||
|
textAreaRef = el;
|
||||||
|
}}
|
||||||
mode="reply"
|
mode="reply"
|
||||||
replyTo={props.event}
|
replyTo={props.event}
|
||||||
onClose={closeReplyForm}
|
onClose={closeReplyForm}
|
||||||
|
|||||||
Reference in New Issue
Block a user