fix translations for singleton (#11697)

This commit is contained in:
Azri Kahar
2022-02-18 23:21:26 +08:00
committed by GitHub
parent 0dadccb822
commit abb2ecdf2e

View File

@@ -293,13 +293,16 @@ export default defineComponent({
watch(
() => props.value,
(newVal, oldVal) => {
if (newVal && !oldVal && !isEqual(newVal, oldVal) && isUndo.value === false) {
loadItems();
}
if (newVal === null || newVal.length === 0) {
items.value = [];
}
if (!newVal && oldVal) return; // when user clears whole translations value
if (newVal && newVal.some((item) => typeof item === 'object') && oldVal) return; // when there's any new edits since edits are objects
if (isEqual(newVal, oldVal)) return; // when user unfocus/blur inputs so they will be equal
if (isUndo.value) return; // when user undo to the original value
loadItems();
},
{ immediate: true }
);