From 3d65eccf047f1fbe4479559aa4a04902fd3a143c Mon Sep 17 00:00:00 2001 From: Hazel Koehler Date: Sat, 16 Dec 2023 13:37:59 -0500 Subject: [PATCH 1/3] use main emoji button for spoiler / CW field --- .../post_status_form/post_status_form.js | 19 ++++++++++++++++--- .../post_status_form/post_status_form.vue | 5 +++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 5647a9eb..b648b50c 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -213,7 +213,9 @@ const PostStatusForm = { preview: null, previewLoading: false, emojiInputShown: false, - idempotencyKey: '' + idempotencyKey: '', + activeEmojiInput: undefined, + activeTextInput: undefined } }, computed: { @@ -674,8 +676,19 @@ const PostStatusForm = { this.$refs['emoji-input'].resize() }, showEmojiPicker () { - this.$refs['textarea'].focus() - this.$refs['emoji-input'].triggerShowPicker() + if (!this.activeEmojiInput || !this.activeTextInput) + this.focusStatusInput() + + this.$refs[this.activeTextInput].focus() + this.$refs[this.activeEmojiInput].triggerShowPicker() + }, + focusStatusInput() { + this.activeEmojiInput = 'emoji-input' + this.activeTextInput = 'textarea' + }, + focusSubjectInput() { + this.activeEmojiInput = 'subject-emoji-input' + this.activeTextInput = 'subject-input' }, clearError () { this.error = null diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue index f4680336..601b7d0c 100644 --- a/src/components/post_status_form/post_status_form.vue +++ b/src/components/post_status_form/post_status_form.vue @@ -118,13 +118,16 @@ />

Date: Sat, 16 Dec 2023 14:44:26 -0500 Subject: [PATCH 2/3] add button to toggle the spoiler / CW field --- .../post_status_form/post_status_form.js | 21 ++++++++++++++++++- .../post_status_form/post_status_form.vue | 18 ++++++++++++++-- src/i18n/en.json | 1 + 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index b648b50c..3bc6dc99 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -199,6 +199,10 @@ const PostStatusForm = { } } + // When first loading the form, hide the subject (CW) field if it's disabled or doesn't have a starting value. + // "disableSubject" seems to take priority over "alwaysShowSubject" + const showSubject = !this.disableSubject && (statusParams.spoilerText || this.alwaysShowSubject) + return { dropFiles: [], uploadingFiles: false, @@ -215,7 +219,8 @@ const PostStatusForm = { emojiInputShown: false, idempotencyKey: '', activeEmojiInput: undefined, - activeTextInput: undefined + activeTextInput: undefined, + subjectVisible: showSubject } }, computed: { @@ -690,6 +695,20 @@ const PostStatusForm = { this.activeEmojiInput = 'subject-emoji-input' this.activeTextInput = 'subject-input' }, + toggleSubjectVisible() { + // If hiding CW, then we need to clear the subject and reset focus + if (this.subjectVisible) + { + this.focusStatusInput() + + // "nsfw" property is normally set by the @change listener, but this bypasses it. + // We need to clear it manually instead. + this.newStatus.spoilerText = '' + this.newStatus.nsfw = false + } + + this.subjectVisible = !this.subjectVisible + }, clearError () { this.error = null }, diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue index 601b7d0c..74663fd7 100644 --- a/src/components/post_status_form/post_status_form.vue +++ b/src/components/post_status_form/post_status_form.vue @@ -119,7 +119,7 @@ +