From 0c7a82d3483b01a4f81114240ff4f7a62948b313 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Mon, 19 Aug 2024 09:54:47 +0000 Subject: [PATCH] blubber: compute height without padding so that the textarea won't grow... Closes #4413 Merge request studip/studip!3276 --- resources/vue/components/blubber/Comment.vue | 21 +++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/resources/vue/components/blubber/Comment.vue b/resources/vue/components/blubber/Comment.vue index 0cc2644d7af..2d4c897933a 100644 --- a/resources/vue/components/blubber/Comment.vue +++ b/resources/vue/components/blubber/Comment.vue @@ -28,14 +28,14 @@ </div> </template> <div v-else class="talk-bubble-edit"> - <textarea - v-model="localText" - ref="textarea" - @input="setTextareaSize" - @focus="setTextareaSize" - @keydown.enter.exact.prevent="saveComment" - @keyup.escape.exact="doneEditing" - ></textarea> + <textarea + v-model="localText" + ref="textarea" + @input="setTextareaSize" + @focus="setTextareaSize" + @keydown.enter.exact.prevent="saveComment" + @keyup.escape.exact="doneEditing" + ></textarea> <button @click="saveComment" :title="$gettext('Speichern')"> <studip-icon shape="accept" /> </button> @@ -121,8 +121,11 @@ export default { }, setTextareaSize() { const textarea = this.$refs.textarea; + const style = getComputedStyle(textarea); + const height = textarea.scrollHeight - parseInt(style.paddingTop, 10) - parseInt(style.paddingBottom, 10); + textarea.style.width = this.commentWidth + 'px'; - textarea.style.height = textarea.scrollHeight + 'px'; + textarea.style.height = height + 'px'; } }, mounted() { -- GitLab