Skip to content

Commit f826cb1

Browse files
committed
feat: wip focus message receivers field when opening new message editor
1 parent ee3b45d commit f826cb1

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/components/layout/Editor.vue

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<div v-if="editorConvoMode">
5151
<!-- Select User -->
5252
<label>To</label>
53-
<Multiselect v-model="msgTagsInput.value" v-bind="msgTagsInput" />
53+
<Multiselect v-model="msgTagsInput.value" v-bind="msgTagsInput" ref="messageReceiverEl" />
5454
<label>Subject</label>
5555
<input type="text" v-model="newMessage.content.subject" minlength="1" maxlength="255" />
5656
<!-- <tags-input min-length="1" placeholder="Type username(s) to message" add-from-autocomplete-only="true" replace-spaces-with-dashes="false" display-property="username" allow-leftover-text="false" ng-model="receivers" modal-focus="{{showEditor && editorConvoMode}}">
@@ -157,9 +157,9 @@
157157

158158
<div class="editor-body" @dragenter.prevent="showDropzone = true" @dragover.prevent="showDropzone = true">
159159
<div class="editor-column-input" :class="{ 'hidden': preview }">
160-
<textarea class="editor-input" v-if="threadEditorMode" v-model="threadCopy.body" :class="{ 'rtl': rtl }" placeholder="Write someting interesting! (BTW, you can drag and drop images directly into the editor panel)" :maxlength="postMaxLength || 10000"></textarea>
161-
<textarea class="editor-input" v-if="postEditorMode" v-model="posting.post.body" :class="{ 'rtl': rtl }" placeholder="Enter your reply here. (BTW, you can drag and drop images directly into the editor panel)" :maxlength="postMaxLength || 10000"></textarea>
162-
<textarea class="editor-input" v-if="editorConvoMode || (!threadEditorMode && !editorConvoMode && !postEditorMode)" v-model="newMessage.content.body" :class="{ 'rtl': rtl }" :placeholder="editorConvoMode ? 'Enter your message here. (BTW, you can drag and drop images directly into the editor panel)' : 'Enter your reply here. (BTW, you can drag and drop images directly into the editor panel)'" :maxlength="postMaxLength || 10000"></textarea>
160+
<textarea class="editor-input" v-if="threadEditorMode" v-model="threadCopy.body" :class="{ 'rtl': rightToLeft }" placeholder="Write someting interesting! (BTW, you can drag and drop images directly into the editor panel)" :maxlength="postMaxLength || 10000"></textarea>
161+
<textarea class="editor-input" v-if="postEditorMode" v-model="posting.post.body" :class="{ 'rtl': rightToLeft }" placeholder="Enter your reply here. (BTW, you can drag and drop images directly into the editor panel)" :maxlength="postMaxLength || 10000" ref="postEditorEl"></textarea>
162+
<textarea class="editor-input" v-if="editorConvoMode || (!threadEditorMode && !editorConvoMode && !postEditorMode)" v-model="newMessage.content.body" :class="{ 'rtl': rightToLeft }" :placeholder="editorConvoMode ? 'Enter your message here. (BTW, you can drag and drop images directly into the editor panel)' : 'Enter your reply here. (BTW, you can drag and drop images directly into the editor panel)'" :maxlength="postMaxLength || 10000" ref="messageEditorEl"></textarea>
163163
<div class="editor-drag-container" :class="{ 'visible': showDropzone}">
164164
<div class="editor-drag">
165165
<div class="editor-drag-text">Drag and Drop Images</div>
@@ -231,7 +231,7 @@
231231
</template>
232232

233233
<script>
234-
import { reactive, toRefs, watch } from 'vue'
234+
import { reactive, toRefs, watch, nextTick } from 'vue'
235235
// import { useRoute, useRouter } from 'vue-router'
236236
import ImageUploader from '@/components/images/ImageUploader.vue'
237237
import Multiselect from '@vueform/multiselect'
@@ -270,6 +270,7 @@ export default {
270270
posting: { post: { title: '', body: '', thread_id: props?.thread?.id }},
271271
newMessage: { content: { subject: '', body: '' } },
272272
rightToLeft: false,
273+
threadTitleEl: null,
273274
msgTagsInput: {
274275
mode: 'tags',
275276
value: [],
@@ -294,6 +295,11 @@ export default {
294295
v.posting.post.title = t.title
295296
})
296297
298+
watch(() => props.showEditor, visible => {
299+
console.log(visible, props.threadEditorMode)
300+
if (visible && props.threadEditorMode) nextTick(() => v.threadTitleEl.focus())
301+
})
302+
297303
return { ...toRefs(v), canLock, canCreate, canUpdate, canSticky, canModerate, canCreatePoll, cancel, closeEditor }
298304
}
299305
}

0 commit comments

Comments
 (0)