fix(client): fix lint issues in autocomplete (#8548)

This commit is contained in:
Andreas Nedbal 2022-04-28 03:56:18 +02:00 committed by GitHub
parent a99cd645bb
commit d0443f9de1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -131,8 +131,8 @@ const props = defineProps<{
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'done', v: { type: string; value: any }): void; (event: 'done', value: { type: string; value: any }): void;
(e: 'closed'): void; (event: 'closed'): void;
}>(); }>();
const suggests = ref<Element>(); const suggests = ref<Element>();
@ -152,7 +152,7 @@ function complete(type: string, value: any) {
emit('closed'); emit('closed');
if (type === 'emoji') { if (type === 'emoji') {
let recents = defaultStore.state.recentlyUsedEmojis; let recents = defaultStore.state.recentlyUsedEmojis;
recents = recents.filter((e: any) => e !== value); recents = recents.filter((emoji: any) => emoji !== value);
recents.unshift(value); recents.unshift(value);
defaultStore.set('recentlyUsedEmojis', recents.splice(0, 32)); defaultStore.set('recentlyUsedEmojis', recents.splice(0, 32));
} }
@ -232,7 +232,7 @@ function exec() {
} else if (props.type === 'emoji') { } else if (props.type === 'emoji') {
if (!props.q || props.q === '') { if (!props.q || props.q === '') {
// 使 // 使
emojis.value = defaultStore.state.recentlyUsedEmojis.map(emoji => emojiDb.find(e => e.emoji === emoji)).filter(x => x) as EmojiDef[]; emojis.value = defaultStore.state.recentlyUsedEmojis.map(emoji => emojiDb.find(dbEmoji => dbEmoji.emoji === emoji)).filter(x => x) as EmojiDef[];
return; return;
} }
@ -269,17 +269,17 @@ function exec() {
} }
} }
function onMousedown(e: Event) { function onMousedown(event: Event) {
if (!contains(rootEl.value, e.target) && (rootEl.value !== e.target)) props.close(); if (!contains(rootEl.value, event.target) && (rootEl.value !== event.target)) props.close();
} }
function onKeydown(e: KeyboardEvent) { function onKeydown(event: KeyboardEvent) {
const cancel = () => { const cancel = () => {
e.preventDefault(); event.preventDefault();
e.stopPropagation(); event.stopPropagation();
}; };
switch (e.key) { switch (event.key) {
case 'Enter': case 'Enter':
if (select.value !== -1) { if (select.value !== -1) {
cancel(); cancel();
@ -310,7 +310,7 @@ function onKeydown(e: KeyboardEvent) {
break; break;
default: default:
e.stopPropagation(); event.stopPropagation();
props.textarea.focus(); props.textarea.focus();
} }
} }