diff options
| author | Kagami Sascha Rosylight <saschanaz@outlook.com> | 2022-12-22 14:28:13 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-22 14:28:13 +0900 |
| commit | 69087f224208cc11385fe9685b7de12c33aad623 (patch) | |
| tree | 39ccc233c77b30286669f593a76527e570f9542d /packages/client/src/components/MkEmojiPicker.vue | |
| parent | 13.0.0-alpha.4 (diff) | |
| download | misskey-69087f224208cc11385fe9685b7de12c33aad623.tar.gz misskey-69087f224208cc11385fe9685b7de12c33aad623.tar.bz2 misskey-69087f224208cc11385fe9685b7de12c33aad623.zip | |
enhance(client): update emoji picker immediately on all input (#9385)
* enhance: update emoji picker immediately on all input
* refactor: remove reference to window.clipboardData
* refactor: done() receives a string
* refactor: typescript-favored `.char` access
Diffstat (limited to 'packages/client/src/components/MkEmojiPicker.vue')
| -rw-r--r-- | packages/client/src/components/MkEmojiPicker.vue | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/packages/client/src/components/MkEmojiPicker.vue b/packages/client/src/components/MkEmojiPicker.vue index 3b446704b5..814f71168a 100644 --- a/packages/client/src/components/MkEmojiPicker.vue +++ b/packages/client/src/components/MkEmojiPicker.vue @@ -1,6 +1,6 @@ <template> <div class="omfetrab" :class="['s' + size, 'w' + width, 'h' + height, { asDrawer }]" :style="{ maxHeight: maxHeight ? maxHeight + 'px' : undefined }"> - <input ref="search" v-model.trim="q" class="search" data-prevent-emoji-insert :class="{ filled: q != null && q != '' }" :placeholder="i18n.ts.search" type="search" @paste.stop="paste" @keyup.enter="done()"> + <input ref="search" :value="q" class="search" data-prevent-emoji-insert :class="{ filled: q != null && q != '' }" :placeholder="i18n.ts.search" type="search" @input="input()" @paste.stop="paste" @keyup.enter="done()"> <div ref="emojis" class="emojis"> <section class="result"> <div v-if="searchResultCustom.length > 0" class="body"> @@ -121,7 +121,7 @@ const width = computed(() => props.asReactionPicker ? reactionPickerWidth.value const height = computed(() => props.asReactionPicker ? reactionPickerHeight.value : 2); const customEmojiCategories = emojiCategories; const customEmojis = instance.emojis; -const q = ref<string | null>(null); +const q = ref<string>(''); const searchResultCustom = ref<Misskey.entities.CustomEmoji[]>([]); const searchResultUnicode = ref<UnicodeEmojiDef[]>([]); const tab = ref<'index' | 'custom' | 'unicode' | 'tags'>('index'); @@ -129,7 +129,7 @@ const tab = ref<'index' | 'custom' | 'unicode' | 'tags'>('index'); watch(q, () => { if (emojis.value) emojis.value.scrollTop = 0; - if (q.value == null || q.value === '') { + if (q.value === '') { searchResultCustom.value = []; searchResultUnicode.value = []; return; @@ -281,7 +281,7 @@ function reset() { } function getKey(emoji: string | Misskey.entities.CustomEmoji | UnicodeEmojiDef): string { - return typeof emoji === 'string' ? emoji : (emoji.char || `:${emoji.name}:`); + return typeof emoji === 'string' ? emoji : 'char' in emoji ? emoji.char : `:${emoji.name}:`; } function chosen(emoji: any, ev?: MouseEvent) { @@ -305,14 +305,21 @@ function chosen(emoji: any, ev?: MouseEvent) { } } -function paste(event: ClipboardEvent) { - const paste = (event.clipboardData || window.clipboardData).getData('text'); - if (done(paste)) { +function input(): void { + // Using custom input event instead of v-model to respond immediately on + // Android, where composition happens on all languages + // (v-model does not update during composition) + q.value = search.value?.value.trim() ?? ''; +} + +function paste(event: ClipboardEvent): void { + const pasted = event.clipboardData?.getData('text') ?? ''; + if (done(pasted)) { event.preventDefault(); } } -function done(query?: any): boolean | void { +function done(query?: string): boolean | void { if (query == null) query = q.value; if (query == null || typeof query !== 'string') return; |