fix: more reliable not closing emoji picker on shift key
This commit is contained in:
parent
05477ee6b4
commit
5b5f997ecf
|
@ -195,7 +195,7 @@ const props = withDefaults(
|
||||||
);
|
);
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(ev: "chosen", v: string): void;
|
(ev: "chosen", v: string, ev: MouseEvent): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const search = ref<HTMLInputElement>();
|
const search = ref<HTMLInputElement>();
|
||||||
|
@ -436,7 +436,7 @@ function chosen(emoji: any, ev?: MouseEvent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const key = getKey(emoji);
|
const key = getKey(emoji);
|
||||||
emit("chosen", key);
|
emit("chosen", key, ev);
|
||||||
|
|
||||||
// 最近使った絵文字更新
|
// 最近使った絵文字更新
|
||||||
if (!pinned.value.includes(key)) {
|
if (!pinned.value.includes(key)) {
|
||||||
|
|
|
@ -58,29 +58,16 @@ const emit = defineEmits<{
|
||||||
|
|
||||||
const modal = ref<InstanceType<typeof MkModal>>();
|
const modal = ref<InstanceType<typeof MkModal>>();
|
||||||
const picker = ref<InstanceType<typeof MkEmojiPicker>>();
|
const picker = ref<InstanceType<typeof MkEmojiPicker>>();
|
||||||
const isShiftKeyPressed = ref(false);
|
|
||||||
|
|
||||||
const keydownHandler = (e) => {
|
|
||||||
if (e.key === "Shift") {
|
|
||||||
isShiftKeyPressed.value = true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const keyupHandler = (e) => {
|
|
||||||
if (e.key === "Shift") {
|
|
||||||
isShiftKeyPressed.value = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function checkForShift(ev?: MouseEvent) {
|
function checkForShift(ev?: MouseEvent) {
|
||||||
if (!isShiftKeyPressed.value) {
|
if (ev?.shiftKey) return;
|
||||||
modal.value?.close(ev);
|
modal.value?.close(ev);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function chosen(emoji: any) {
|
function chosen(emoji: any, ev: MouseEvent) {
|
||||||
emit("done", emoji);
|
emit("done", emoji);
|
||||||
checkForShift();
|
checkForShift(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
function opening() {
|
function opening() {
|
||||||
|
@ -91,16 +78,6 @@ function opening() {
|
||||||
}
|
}
|
||||||
picker.value?.focus();
|
picker.value?.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
window.addEventListener("keydown", keydownHandler);
|
|
||||||
window.addEventListener("keyup", keyupHandler);
|
|
||||||
});
|
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
window.removeEventListener("keydown", keydownHandler);
|
|
||||||
window.removeEventListener("keyup", keyupHandler);
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
Loading…
Reference in New Issue