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 800409fe29
commit ff557baaa9
5 changed files with 23 additions and 13 deletions

View File

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

View File

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

View File

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

View File

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

View File

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