fix emoji picker

This commit is contained in:
tamaina 2023-08-03 03:57:27 +00:00
parent 615e25f4fa
commit 01ff597e65
3 changed files with 17 additions and 5 deletions

View File

@ -12,10 +12,11 @@ SPDX-License-Identifier: AGPL-3.0-only
:transparentBg="true" :transparentBg="true"
:manualShowing="manualShowing" :manualShowing="manualShowing"
:src="src" :src="src"
@click="modal?.close()" @click="click"
@opening="opening" @opening="opening"
@close="emit('close')" @close="emit('close')"
@closed="emit('closed')" @closed="emit('closed')"
@hide="emit('hide')"
> >
<MkEmojiPicker <MkEmojiPicker
ref="picker" ref="picker"
@ -36,7 +37,7 @@ import MkModal from '@/components/MkModal.vue';
import MkEmojiPicker from '@/components/MkEmojiPicker.vue'; import MkEmojiPicker from '@/components/MkEmojiPicker.vue';
import { defaultStore } from '@/store'; import { defaultStore } from '@/store';
withDefaults(defineProps<{ const props = withDefaults(defineProps<{
manualShowing?: boolean | null; manualShowing?: boolean | null;
src?: HTMLElement; src?: HTMLElement;
showPinned?: boolean; showPinned?: boolean;
@ -51,6 +52,8 @@ const emit = defineEmits<{
(ev: 'done', v: any): void; (ev: 'done', v: any): void;
(ev: 'close'): void; (ev: 'close'): void;
(ev: 'closed'): void; (ev: 'closed'): void;
(ev: 'click'): void;
(ev: 'hide'): void;
}>(); }>();
const modal = shallowRef<InstanceType<typeof MkModal>>(); const modal = shallowRef<InstanceType<typeof MkModal>>();
@ -58,7 +61,7 @@ const picker = shallowRef<InstanceType<typeof MkEmojiPicker>>();
function chosen(emoji: any) { function chosen(emoji: any) {
emit('done', emoji); emit('done', emoji);
modal.value?.close(); if (props.manualShowing === null) modal.value?.close();
} }
function opening() { function opening() {
@ -70,6 +73,11 @@ function opening() {
picker.value?.focus(); picker.value?.focus();
}, 10); }, 10);
} }
function click() {
emit('click');
if (props.manualShowing === null) modal.value?.close();
}
</script> </script>
<style lang="scss" module> <style lang="scss" module>

View File

@ -15,7 +15,7 @@ import MkModal from './MkModal.vue';
import MkMenu from './MkMenu.vue'; import MkMenu from './MkMenu.vue';
import { MenuItem } from '@/types/menu'; import { MenuItem } from '@/types/menu';
const props = defineProps<{ defineProps<{
items: MenuItem[]; items: MenuItem[];
align?: 'center' | string; align?: 'center' | string;
width?: number; width?: number;

View File

@ -24,14 +24,18 @@ class ReactionPicker {
}, { }, {
done: reaction => { done: reaction => {
this.onChosen!(reaction); this.onChosen!(reaction);
this.manualShowing.value = false;
}, },
close: () => { close: () => {
this.manualShowing.value = false; this.manualShowing.value = false;
}, },
closed: () => { hide: () => {
this.src.value = null; this.src.value = null;
this.onClosed!(); this.onClosed!();
}, },
click: () => {
this.manualShowing.value = false;
}
}); });
} }