Focus on textarea when maximize from composer button

pull/1096/merge
Lim Chee Aun 2025-09-03 10:48:48 +08:00
rodzic fe8ae64816
commit 4462227139
2 zmienionych plików z 56 dodań i 47 usunięć

Wyświetl plik

@ -9,6 +9,7 @@ import { useHotkeys } from 'react-hotkeys-hook';
import stringLength from 'string-length'; import stringLength from 'string-length';
import { uid } from 'uid/single'; import { uid } from 'uid/single';
import useResizeObserver from 'use-resize-observer'; import useResizeObserver from 'use-resize-observer';
import { useSnapshot } from 'valtio';
import supportedLanguages from '../data/status-supported-languages'; import supportedLanguages from '../data/status-supported-languages';
import { api, getPreferences } from '../utils/api'; import { api, getPreferences } from '../utils/api';
@ -382,6 +383,14 @@ function Compose({
} }
}, [draftStatus, editStatus, replyToStatus]); }, [draftStatus, editStatus, replyToStatus]);
// focus textarea when state.composerState.minimized turns false
const snapStates = useSnapshot(states);
useEffect(() => {
if (!snapStates.composerState.minimized) {
focusTextarea();
}
}, [snapStates.composerState.minimized]);
const formRef = useRef(); const formRef = useRef();
const beforeUnloadCopy = t`You have unsaved changes. Discard this post?`; const beforeUnloadCopy = t`You have unsaved changes. Discard this post?`;

94
src/locales/en.po wygenerowano
Wyświetl plik

@ -91,7 +91,7 @@ msgstr "Go to account page"
#: src/components/account-info.jsx:407 #: src/components/account-info.jsx:407
#: src/components/account-info.jsx:740 #: src/components/account-info.jsx:740
#: src/components/compose.jsx:1695 #: src/components/compose.jsx:1704
#: src/pages/settings.jsx:324 #: src/pages/settings.jsx:324
#: src/utils/visibility-text.jsx:7 #: src/utils/visibility-text.jsx:7
msgid "Followers" msgid "Followers"
@ -251,7 +251,7 @@ msgstr "View post stats"
#: src/components/account-sheet.jsx:38 #: src/components/account-sheet.jsx:38
#: src/components/add-remove-lists-sheet.jsx:45 #: src/components/add-remove-lists-sheet.jsx:45
#: src/components/compose.jsx:888 #: src/components/compose.jsx:897
#: src/components/custom-emojis-modal.jsx:234 #: src/components/custom-emojis-modal.jsx:234
#: src/components/drafts.jsx:57 #: src/components/drafts.jsx:57
#: src/components/edit-profile-sheet.jsx:87 #: src/components/edit-profile-sheet.jsx:87
@ -370,7 +370,7 @@ msgid "Remove"
msgstr "" msgstr ""
#: src/components/compose-poll.jsx:80 #: src/components/compose-poll.jsx:80
#: src/components/compose.jsx:1424 #: src/components/compose.jsx:1433
#: src/components/mention-modal.jsx:220 #: src/components/mention-modal.jsx:220
#: src/components/shortcuts-settings.jsx:715 #: src/components/shortcuts-settings.jsx:715
#: src/pages/list.jsx:388 #: src/pages/list.jsx:388
@ -389,174 +389,174 @@ msgstr ""
msgid "Remove poll" msgid "Remove poll"
msgstr "" msgstr ""
#: src/components/compose.jsx:101 #: src/components/compose.jsx:102
msgid "Take photo or video" msgid "Take photo or video"
msgstr "Take photo or video" msgstr "Take photo or video"
#: src/components/compose.jsx:102 #: src/components/compose.jsx:103
msgid "Add media" msgid "Add media"
msgstr "Add media" msgstr "Add media"
#: src/components/compose.jsx:103 #: src/components/compose.jsx:104
msgid "Add custom emoji" msgid "Add custom emoji"
msgstr "" msgstr ""
#: src/components/compose.jsx:104 #: src/components/compose.jsx:105
msgid "Add GIF" msgid "Add GIF"
msgstr "Add GIF" msgstr "Add GIF"
#: src/components/compose.jsx:105 #: src/components/compose.jsx:106
msgid "Add poll" msgid "Add poll"
msgstr "" msgstr ""
#: src/components/compose.jsx:106 #: src/components/compose.jsx:107
msgid "Add content warning" msgid "Add content warning"
msgstr "Add content warning" msgstr "Add content warning"
#: src/components/compose.jsx:107 #: src/components/compose.jsx:108
msgid "Schedule post" msgid "Schedule post"
msgstr "Schedule post" msgstr "Schedule post"
#: src/components/compose.jsx:387 #: src/components/compose.jsx:396
msgid "You have unsaved changes. Discard this post?" msgid "You have unsaved changes. Discard this post?"
msgstr "You have unsaved changes. Discard this post?" msgstr "You have unsaved changes. Discard this post?"
#. placeholder {0}: unsupportedFiles.length #. placeholder {0}: unsupportedFiles.length
#. placeholder {1}: unsupportedFiles[0].name #. placeholder {1}: unsupportedFiles[0].name
#. placeholder {2}: lf.format( unsupportedFiles.map((f) => f.name), ) #. placeholder {2}: lf.format( unsupportedFiles.map((f) => f.name), )
#: src/components/compose.jsx:626 #: src/components/compose.jsx:635
msgid "{0, plural, one {File {1} is not supported.} other {Files {2} are not supported.}}" msgid "{0, plural, one {File {1} is not supported.} other {Files {2} are not supported.}}"
msgstr "{0, plural, one {File {1} is not supported.} other {Files {2} are not supported.}}" msgstr "{0, plural, one {File {1} is not supported.} other {Files {2} are not supported.}}"
#: src/components/compose.jsx:636 #: src/components/compose.jsx:645
#: src/components/compose.jsx:654 #: src/components/compose.jsx:663
#: src/components/compose.jsx:1780 #: src/components/compose.jsx:1789
#: src/components/file-picker-input.jsx:38 #: src/components/file-picker-input.jsx:38
msgid "{maxMediaAttachments, plural, one {You can only attach up to 1 file.} other {You can only attach up to # files.}}" msgid "{maxMediaAttachments, plural, one {You can only attach up to 1 file.} other {You can only attach up to # files.}}"
msgstr "" msgstr ""
#: src/components/compose.jsx:869 #: src/components/compose.jsx:878
msgid "Pop out" msgid "Pop out"
msgstr "Pop out" msgstr "Pop out"
#: src/components/compose.jsx:876 #: src/components/compose.jsx:885
msgid "Minimize" msgid "Minimize"
msgstr "Minimize" msgstr "Minimize"
#: src/components/compose.jsx:912 #: src/components/compose.jsx:921
msgid "Looks like you closed the parent window." msgid "Looks like you closed the parent window."
msgstr "Looks like you closed the parent window." msgstr "Looks like you closed the parent window."
#: src/components/compose.jsx:919 #: src/components/compose.jsx:928
msgid "Looks like you already have a compose field open in the parent window and currently publishing. Please wait for it to be done and try again later." msgid "Looks like you already have a compose field open in the parent window and currently publishing. Please wait for it to be done and try again later."
msgstr "Looks like you already have a compose field open in the parent window and currently publishing. Please wait for it to be done and try again later." msgstr "Looks like you already have a compose field open in the parent window and currently publishing. Please wait for it to be done and try again later."
#: src/components/compose.jsx:924 #: src/components/compose.jsx:933
msgid "Looks like you already have a compose field open in the parent window. Popping in this window will discard the changes you made in the parent window. Continue?" msgid "Looks like you already have a compose field open in the parent window. Popping in this window will discard the changes you made in the parent window. Continue?"
msgstr "Looks like you already have a compose field open in the parent window. Popping in this window will discard the changes you made in the parent window. Continue?" msgstr "Looks like you already have a compose field open in the parent window. Popping in this window will discard the changes you made in the parent window. Continue?"
#: src/components/compose.jsx:968 #: src/components/compose.jsx:977
msgid "Pop in" msgid "Pop in"
msgstr "Pop in" msgstr "Pop in"
#. placeholder {0}: replyToStatus.account.acct || replyToStatus.account.username #. placeholder {0}: replyToStatus.account.acct || replyToStatus.account.username
#. placeholder {1}: rtf.format(-replyToStatusMonthsAgo, 'month') #. placeholder {1}: rtf.format(-replyToStatusMonthsAgo, 'month')
#: src/components/compose.jsx:978 #: src/components/compose.jsx:987
msgid "Replying to @{0}s post (<0>{1}</0>)" msgid "Replying to @{0}s post (<0>{1}</0>)"
msgstr "" msgstr ""
#. placeholder {0}: replyToStatus.account.acct || replyToStatus.account.username #. placeholder {0}: replyToStatus.account.acct || replyToStatus.account.username
#: src/components/compose.jsx:988 #: src/components/compose.jsx:997
msgid "Replying to @{0}s post" msgid "Replying to @{0}s post"
msgstr "" msgstr ""
#: src/components/compose.jsx:1001 #: src/components/compose.jsx:1010
msgid "Editing source post" msgid "Editing source post"
msgstr "" msgstr ""
#: src/components/compose.jsx:1069 #: src/components/compose.jsx:1078
msgid "Poll must have at least 2 options" msgid "Poll must have at least 2 options"
msgstr "Poll must have at least 2 options" msgstr "Poll must have at least 2 options"
#: src/components/compose.jsx:1073 #: src/components/compose.jsx:1082
msgid "Some poll choices are empty" msgid "Some poll choices are empty"
msgstr "Some poll choices are empty" msgstr "Some poll choices are empty"
#: src/components/compose.jsx:1086 #: src/components/compose.jsx:1095
msgid "Some media have no descriptions. Continue?" msgid "Some media have no descriptions. Continue?"
msgstr "Some media have no descriptions. Continue?" msgstr "Some media have no descriptions. Continue?"
#: src/components/compose.jsx:1138 #: src/components/compose.jsx:1147
msgid "Attachment #{i} failed" msgid "Attachment #{i} failed"
msgstr "Attachment #{i} failed" msgstr "Attachment #{i} failed"
#: src/components/compose.jsx:1247 #: src/components/compose.jsx:1256
#: src/components/status.jsx:2096 #: src/components/status.jsx:2096
#: src/components/timeline.jsx:1015 #: src/components/timeline.jsx:1015
msgid "Content warning" msgid "Content warning"
msgstr "" msgstr ""
#: src/components/compose.jsx:1268 #: src/components/compose.jsx:1277
#: src/components/compose.jsx:1401 #: src/components/compose.jsx:1410
#: src/components/edit-profile-sheet.jsx:323 #: src/components/edit-profile-sheet.jsx:323
#: src/components/private-note-sheet.jsx:94 #: src/components/private-note-sheet.jsx:94
msgid "Cancel" msgid "Cancel"
msgstr "" msgstr ""
#: src/components/compose.jsx:1276 #: src/components/compose.jsx:1285
msgid "Post your reply" msgid "Post your reply"
msgstr "Post your reply" msgstr "Post your reply"
#: src/components/compose.jsx:1278 #: src/components/compose.jsx:1287
msgid "Edit your post" msgid "Edit your post"
msgstr "Edit your post" msgstr "Edit your post"
#: src/components/compose.jsx:1280 #: src/components/compose.jsx:1289
msgid "Ask a question" msgid "Ask a question"
msgstr "Ask a question" msgstr "Ask a question"
#: src/components/compose.jsx:1281 #: src/components/compose.jsx:1290
msgid "What are you doing?" msgid "What are you doing?"
msgstr "What are you doing?" msgstr "What are you doing?"
#: src/components/compose.jsx:1351 #: src/components/compose.jsx:1360
msgid "Mark media as sensitive" msgid "Mark media as sensitive"
msgstr "" msgstr ""
#: src/components/compose.jsx:1381 #: src/components/compose.jsx:1390
msgid "Posting on <0/>" msgid "Posting on <0/>"
msgstr "Posting on <0/>" msgstr "Posting on <0/>"
#: src/components/compose.jsx:1683 #: src/components/compose.jsx:1692
#: src/pages/settings.jsx:318 #: src/pages/settings.jsx:318
#: src/utils/visibility-text.jsx:4 #: src/utils/visibility-text.jsx:4
msgid "Public" msgid "Public"
msgstr "" msgstr ""
#: src/components/compose.jsx:1688 #: src/components/compose.jsx:1697
#: src/components/nav-menu.jsx:349 #: src/components/nav-menu.jsx:349
#: src/components/shortcuts-settings.jsx:165 #: src/components/shortcuts-settings.jsx:165
#: src/utils/visibility-text.jsx:5 #: src/utils/visibility-text.jsx:5
msgid "Local" msgid "Local"
msgstr "" msgstr ""
#: src/components/compose.jsx:1692 #: src/components/compose.jsx:1701
#: src/pages/settings.jsx:321 #: src/pages/settings.jsx:321
#: src/utils/visibility-text.jsx:6 #: src/utils/visibility-text.jsx:6
msgid "Quiet public" msgid "Quiet public"
msgstr "Quiet public" msgstr "Quiet public"
#: src/components/compose.jsx:1698 #: src/components/compose.jsx:1707
#: src/components/status.jsx:1976 #: src/components/status.jsx:1976
#: src/utils/visibility-text.jsx:8 #: src/utils/visibility-text.jsx:8
msgid "Private mention" msgid "Private mention"
msgstr "" msgstr ""
#: src/components/compose.jsx:1704 #: src/components/compose.jsx:1713
msgid "Schedule" msgid "Schedule"
msgstr "Schedule" msgstr "Schedule"
#: src/components/compose.jsx:1706 #: src/components/compose.jsx:1715
#: src/components/keyboard-shortcuts-help.jsx:155 #: src/components/keyboard-shortcuts-help.jsx:155
#: src/components/status.jsx:958 #: src/components/status.jsx:958
#: src/components/status.jsx:1744 #: src/components/status.jsx:1744
@ -565,20 +565,20 @@ msgstr "Schedule"
msgid "Reply" msgid "Reply"
msgstr "" msgstr ""
#: src/components/compose.jsx:1708 #: src/components/compose.jsx:1717
msgid "Update" msgid "Update"
msgstr "Update" msgstr "Update"
#: src/components/compose.jsx:1709 #: src/components/compose.jsx:1718
msgctxt "Submit button in composer" msgctxt "Submit button in composer"
msgid "Post" msgid "Post"
msgstr "Post" msgstr "Post"
#: src/components/compose.jsx:1792 #: src/components/compose.jsx:1801
msgid "Downloading GIF…" msgid "Downloading GIF…"
msgstr "Downloading GIF…" msgstr "Downloading GIF…"
#: src/components/compose.jsx:1820 #: src/components/compose.jsx:1829
msgid "Failed to download GIF" msgid "Failed to download GIF"
msgstr "Failed to download GIF" msgstr "Failed to download GIF"