Makes each metatada type decide if its input should debounce or not.

This commit is contained in:
mateuswetah 2024-08-06 15:22:02 -03:00
parent 883b5a4574
commit ffaede4317
5 changed files with 23 additions and 13 deletions

View File

@ -69,8 +69,11 @@
else
value = Number(value);
this.$emit('update:value', value);
this.changeValue(value);
},
changeValue: _.debounce(function(value) {
this.$emit('update:value', value);
}, 800),
onBlur() {
this.$emit('blur');
},

View File

@ -77,7 +77,7 @@
:is-mobile-screen="isMobileScreen"
:is-focused="isFocused"
:is-metadata-navigation="isMetadataNavigation"
@update:value="changeValue"
@update:value="performValueChange"
@blur="performValueChange"
@mobile-special-focus="onMobileSpecialFocus" />
<template v-if="isMultiple && values.length > 1">
@ -102,7 +102,7 @@
:is-mobile-screen="isMobileScreen"
:is-focused="isFocused"
:is-metadata-navigation="isMetadataNavigation"
@update:value="changeValue"
@update:value="performValueChange"
@blur="performValueChange"
@mobile-special-focus="onMobileSpecialFocus" />
<a
@ -159,7 +159,7 @@
:is-focused="isFocused"
:is-metadata-navigation="isMetadataNavigation"
:enumerate-metadatum="enumerateMetadatum"
@update:value="changeValue"
@update:value="performValueChange"
@blur="performValueChange"
@mobile-special-focus="onMobileSpecialFocus" />
</div>
@ -285,11 +285,8 @@
this.itemMetadatum.value == null || this.itemMetadatum.value == undefined ? this.values = [] : this.values.push(this.itemMetadatum.value);
}
},
changeValue: _.debounce(function() {
this.performValueChange();
}, 800),
performValueChange() {
// Compound metadata do not emit values, only their children.
if (this.metadatumComponent == 'tainacan-compound')
return;
@ -353,11 +350,11 @@
},
addValue(){
this.values.push('');
this.changeValue();
this.performValueChange();
},
removeValue(index) {
this.values.splice(index, 1);
this.changeValue();
this.performValueChange();
},
onMobileSpecialFocus() {
if (this.isMobileScreen)

View File

@ -127,8 +127,11 @@
if ( inputRef && this.getMaxlength && !inputRef.checkHtml5Validity() )
return;
this.$emit('update:value', value);
this.changeValue(value);
},
changeValue: _.debounce(function(value) {
this.$emit('update:value', value);
}, 750),
onBlur() {
this.isInputFocused = false;
this.$emit('blur');

View File

@ -38,8 +38,11 @@
if ( inputRef && this.getMaxlength && !inputRef.checkHtml5Validity() )
return;
this.$emit('update:value', value);
this.changeValue(value);
},
changeValue: _.debounce(function(value) {
this.$emit('update:value', value);
}, 750),
onBlur() {
this.$emit('blur');
},

View File

@ -47,8 +47,12 @@ export default {
onInput(value) {
this.isPreviewingHtml = false;
this.singleHTMLPreview = '';
this.$emit('update:value', value);
this.changeValue(value);
},
changeValue: _.debounce(function(value) {
this.$emit('update:value', value);
}, 750),
onBlur() {
this.$emit('blur');
},