Skip to content

Commit

Permalink
fix: check if extraParams are really changing
Browse files Browse the repository at this point in the history
  • Loading branch information
annacv committed Sep 30, 2024
1 parent 08467db commit 97d3e28
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,25 @@
},
setup(props) {
const snippetConfig = inject('snippetConfig') as SnippetConfig;
const extraParams = ref({});
const extraParams = ref<Record<string, unknown>>({});
const initialExtraParams = ref<Record<string, unknown>>({});
watch(
[() => snippetConfig, () => props.values],
() => {
const newExtraParams: Record<string, unknown> = {};
forEach({ ...props.values, ...snippetConfig }, (name, value) => {
if (!props.excludedExtraParams.includes(name)) {
extraParams.value = { ...extraParams.value, [name]: value };
newExtraParams[name] = value;
}
});
// Check if extraParams are really changing to avoid event emission if they don't
if (JSON.stringify(newExtraParams) !== JSON.stringify(initialExtraParams.value)) {
extraParams.value = newExtraParams;
initialExtraParams.value = newExtraParams;
}
},
{
deep: true,
Expand Down

0 comments on commit 97d3e28

Please sign in to comment.