From caf7b28b2226c3ab342acbb4dc74ec18e34a4dc6 Mon Sep 17 00:00:00 2001 From: silverpill Date: Sun, 15 May 2022 22:21:25 +0000 Subject: [PATCH] Resize post form after submitting --- src/components/PostEditor.vue | 5 ++++- src/utils/autoresize.ts | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/PostEditor.vue b/src/components/PostEditor.vue index d8ca512..bdb2cb1 100644 --- a/src/components/PostEditor.vue +++ b/src/components/PostEditor.vue @@ -103,7 +103,7 @@ import Avatar from "@/components/Avatar.vue" import VisibilityIcon from "@/components/VisibilityIcon.vue" import { useInstanceInfo } from "@/store/instance" import { useCurrentUser } from "@/store/user" -import { setupAutoResize } from "@/utils/autoresize" +import { setupAutoResize, triggerResize } from "@/utils/autoresize" import { renderMarkdownLite } from "@/utils/markdown" import { fileToDataUrl, dataUrlToBase64 } from "@/utils/upload" @@ -218,6 +218,9 @@ export default class PostEditor extends Vue { this.errorMessage = null this.attachment = null this.content = "" + this.$nextTick(() => { + triggerResize(this.$refs.postFormContent) + }) this.$emit("post-created", post) } diff --git a/src/utils/autoresize.ts b/src/utils/autoresize.ts index 6707f14..bc51127 100644 --- a/src/utils/autoresize.ts +++ b/src/utils/autoresize.ts @@ -6,3 +6,7 @@ export function setupAutoResize(textarea: HTMLTextAreaElement) { textarea.style.height = `${textarea.scrollHeight}px` }, false) } + +export function triggerResize(textarea: HTMLTextAreaElement) { + textarea.dispatchEvent(new Event("input")) +}