From 0df02813a05d13cc0f1dea675bc2c209939bbbb4 Mon Sep 17 00:00:00 2001 From: Ahmed Awan Date: Tue, 1 Oct 2024 11:34:56 -0500 Subject: [PATCH] fix reactivity of `ClickToEdit` and add some styling --- .../ListDatasetCollectionElementView.vue | 2 +- .../Collections/common/ClickToEdit.vue | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/client/src/components/Collections/ListDatasetCollectionElementView.vue b/client/src/components/Collections/ListDatasetCollectionElementView.vue index c6160c7ba879..0f17767c203b 100644 --- a/client/src/components/Collections/ListDatasetCollectionElementView.vue +++ b/client/src/components/Collections/ListDatasetCollectionElementView.vue @@ -43,7 +43,7 @@ function clickDiscard() { {{ element.hid }}: - + ({{ element.extension }}) diff --git a/client/src/components/Collections/common/ClickToEdit.vue b/client/src/components/Collections/common/ClickToEdit.vue index 84c413d7f1f1..b77925d65a1d 100644 --- a/client/src/components/Collections/common/ClickToEdit.vue +++ b/client/src/components/Collections/common/ClickToEdit.vue @@ -2,7 +2,7 @@ import { faSave } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; import { BButton } from "bootstrap-vue"; -import { ref, watch } from "vue"; +import { computed, ref, watch } from "vue"; interface Props { value: string; @@ -18,12 +18,13 @@ const emit = defineEmits<{ const editable = ref(false); const localValue = ref(props.value); +const computedValue = computed(() => props.value); + watch( () => editable.value, (value) => { if (!value) { emit("input", localValue.value); - localValue.value = props.value; } } ); @@ -34,10 +35,9 @@ watch( @@ -50,15 +50,20 @@ watch( v-else role="button" for="click-to-edit-input" + class="click-to-edit-label" tabindex="0" @keyup.enter="editable = true" @click.stop="editable = true"> - {{ localValue }} + {{ computedValue }} + {{ title }}