diff --git a/src/views/admin/components/metadata-types/text/TainacanText.vue b/src/views/admin/components/metadata-types/text/TainacanText.vue
index e1aa123f4..d3f71dcee 100644
--- a/src/views/admin/components/metadata-types/text/TainacanText.vue
+++ b/src/views/admin/components/metadata-types/text/TainacanText.vue
@@ -8,7 +8,7 @@
v-imask="getMask"
class="input"
:disabled="disabled"
- :value="value"
+ :value="localValue"
:placeholder="itemMetadatum.metadatum.placeholder ? itemMetadatum.metadatum.placeholder : ''"
:maxlength="getMaxlength"
@focus="onMobileSpecialFocus"
@@ -16,17 +16,17 @@
@input="($event) => getMask ? null : onInput($event.target.value)"
@blur="onBlur">
- {{ value.length }} / {{ getMaxlength }}
+ {{ localValue.length }} / {{ getMaxlength }}
onInput($event)"
@blur="onBlur" />
@@ -11,7 +11,7 @@
v-if="itemMetadatum.item.id"
class="add-new-term">
@@ -39,15 +39,20 @@ export default {
emits: [ 'update:value', 'blur' ],
data() {
return {
+ localValue: '',
isPreviewingHtml: false,
singleHTMLPreview: ''
}
},
+ created() {
+ this.localValue = this.value ? JSON.parse(JSON.stringify(this.value)) : '';
+ },
methods: {
onInput(value) {
this.isPreviewingHtml = false;
this.singleHTMLPreview = '';
+ this.localValue = value;
this.changeValue(value);
},
changeValue: _.debounce(function(value) {
@@ -63,7 +68,7 @@ export default {
},
previewHtml() {
// If we are going to display preview, renders it
- if (!this.isPreviewingHtml) {
+ if ( !this.isPreviewingHtml ) {
// Multivalued metadata need to be split as the values_as_html shows every value
if (this.itemMetadatum.metadatum.multiple == 'yes') {
@@ -71,7 +76,7 @@ export default {
const valuesAsHtml = this.createElementFromHTML(this.itemMetadatum.value_as_html);
const valuesAsArray = Object.values(valuesAsHtml.children).filter((aValue) => aValue.outerHTML != ' | ');
- const singleValueIndex = this.itemMetadatum.value.findIndex((aValue) => aValue == this.value);
+ const singleValueIndex = this.itemMetadatum.value.findIndex((aValue) => aValue == this.localValue);
if (singleValueIndex >= 0)
this.singleHTMLPreview = valuesAsArray[singleValueIndex].outerHTML;