Skip to content

Commit

Permalink
Fix: Populate subcategory dialog fields on initial load after page re…
Browse files Browse the repository at this point in the history
…fresh

- Added logic to initialize 'Name' and 'Description' fields with existing values when the dialog is opened for the first time after a page refresh.
- Implemented a watcher to ensure that fields are pre-filled with the correct data, preventing users from having to retype entire fields for minor edits.
  • Loading branch information
UmakanthKaspa committed Aug 30, 2024
1 parent 464c7f8 commit 3b80c7e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions desk/src/pages/knowledge-base/KnowledgeBaseSubcategory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@
<div class="space-y-4">
<FormControl
v-model="newSubCategoryName"
:placeholder="subCategory.doc.category_name"
placeholder="Name"
label="Name"
type="text"
/>
<FormControl
v-model="newSubCategoryDescription"
:placeholder="subCategory.doc.description"
placeholder="Description"
label="Description"
type="textarea"
/>
Expand All @@ -80,7 +80,7 @@
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
import { ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router";
import {
createDocumentResource,
Expand Down Expand Up @@ -122,6 +122,13 @@ const subCategory = createDocumentResource({
},
});
watch(showEdit, (newValue) => {
if (newValue) {
newSubCategoryName.value = subCategory.doc?.category_name || "";
newSubCategoryDescription.value = subCategory.doc?.description || "";
}
});
const saveSubCategory = debounce(
() =>
subCategory.setValue.submit({
Expand Down

0 comments on commit 3b80c7e

Please sign in to comment.