Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Add BBAutoResize to autoresize text area height and make comment text area use it

Tianzhou Chen974cb3236b52
diff --git a/frontend/src/bbkit/BBAutoResize.vue b/frontend/src/bbkit/BBAutoResize.vue
new file mode 100644
index 0000000000..0486c10cfb
--- /dev/null
+++ b/frontend/src/bbkit/BBAutoResize.vue
@@ -0,0 +1,37 @@
+<template>
+ <div ref="control">
+ <slot :resize="resize" />
+ </div>
+</template>
+
+<script lang="ts">
+import { onMounted, nextTick, ref } from "vue";
+
+export default {
+ name: "ResizeAuto",
+ setup(props, ctx) {
+ const control = ref();
+
+ onMounted(() => {
+ nextTick(() => {
+ control.value.setAttribute(
+ "style",
+ "height",
+ `${control.value.scrollHeight}px`
+ );
+ });
+ });
+
+ const resize = (e: Event) => {
+ const target = e.target as HTMLTextAreaElement;
+ target.style.height = "auto";
+ target.style.height = `${target.scrollHeight}px`;
+ };
+
+ return {
+ control,
+ resize,
+ };
+ },
+};
+</script>
diff --git a/frontend/src/bbkit/index.ts b/frontend/src/bbkit/index.ts
index 17cf1f0361..9a65bc62e5 100644
--- a/frontend/src/bbkit/index.ts
+++ b/frontend/src/bbkit/index.ts
@@ -1,4 +1,5 @@
import BBAlert from "./BBAlert.vue";
+import BBAutoResize from "./BBAutoResize.vue";
import BBAvatar from "./BBAvatar.vue";
import BBContextMenu from "./BBContextMenu.vue";
import BBModal from "./BBModal.vue";
@@ -10,6 +11,7 @@ import { BBTable, BBTableCell, BBTableTabFilter } from "./BBTable";
export {
BBAlert,
+ BBAutoResize,
BBAvatar,
BBContextMenu,
BBModal,
diff --git a/frontend/src/main.js b/frontend/src/main.js
index a085e7217c..77ccd42469 100644
--- a/frontend/src/main.js
+++ b/frontend/src/main.js
@@ -8,6 +8,7 @@ import "./assets/css/tailwind.css";
import { makeServer } from "./miragejs/server";
import {
BBAlert,
+ BBAutoResize,
BBAvatar,
BBContextMenu,
BBModal,
@@ -38,6 +39,7 @@ app
.use(store)
.use(router)
.component("BBAlert", BBAlert)
+ .component("BBAutoResize", BBAutoResize)
.component("BBAvatar", BBAvatar)
.component("BBContextMenu", BBContextMenu)
.component("BBModal", BBModal)
diff --git a/frontend/src/views/TaskActivityPanel.vue b/frontend/src/views/TaskActivityPanel.vue
index 8022f83129..ff23e853d8 100644
--- a/frontend/src/views/TaskActivityPanel.vue
+++ b/frontend/src/views/TaskActivityPanel.vue
@@ -118,13 +118,18 @@
<form action="#">
<div>
<label for="comment" class="sr-only">Comment</label>
- <textarea
- id="comment"
- name="comment"
- rows="3"
- class="shadow-sm block w-full focus:ring-gray-900 focus:border-gray-900 sm:text-sm border-gray-300 rounded-md"
- placeholder="Leave a comment..."
- ></textarea>
+ <BBAutoResize>
+ <template v-slot:default="{ resize }">
+ <textarea
+ id="comment"
+ name="comment"
+ rows="3"
+ class="overflow-y-hidden shadow-sm block w-full focus:ring-gray-900 focus:border-gray-900 sm:text-sm border-gray-300 rounded-md"
+ placeholder="Leave a comment..."
+ @input="resize"
+ ></textarea>
+ </template>
+ </BBAutoResize>
</div>
<div class="mt-6 flex items-center justify-start space-x-4">
<button