Skip to content

Conversation

tskarhed
Copy link
Contributor

@tskarhed tskarhed commented Sep 5, 2025

Previously, this would cause a change event every time some url reloading would happen.

@tskarhed tskarhed requested a review from dprokop September 5, 2025 14:14
@tskarhed tskarhed changed the title ScopesVariable: Don't update when just newScopes are empty ScopesVariable: Don't update when only newScopes are empty Sep 5, 2025
@tskarhed tskarhed changed the title ScopesVariable: Don't update when only newScopes are empty ScopesVariable: Add flag for emitting on initial load Sep 5, 2025
@tskarhed tskarhed added the patch Increment the patch version when merged label Sep 5, 2025

// Only update scopes value state when loading is false and the scopes have changed
if (!loading && (scopesHaveChanged || newScopes.length === 0)) {
// Emit on initial load to ensure that the variable is updated when the scopes are empty
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, this would cause a change event every time some url reloading would happen.

what do you mean by 'url reloading' ?

why would scopesHaveChanged be true and need to be ignored?

Copy link
Collaborator

@torkelo torkelo Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, is it the scenario where newScopes.length === 0?

hm... why is state updated with new empty scopes array on every url update?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was noticed when switching on/off edit mode in dashboards, with empty set of scopes. I would assume that the URL change it causes also makes the scopes update?

Regardless, I think newScopes.length === 0 is weird check that doesn't really do what it is supposed to. scopesHaveChanged is not true for the initial load.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tskarhed but why is stateObservable emitting a new scope value when going into/out of edit mode?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@torkelo apparently this only happens when no scope is selected. @tskarhed is there any special handling for such case with empty scopes? I don't understand why this problem only occurs with scopes being empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tskarhed but why is stateObservable emitting a new scope value when going into/out of edit mode?

I'll see if I can look further into it next week.

@torkelo apparently this only happens when no scope is selected. @tskarhed is there any special handling for such case with empty scopes? I don't understand why this problem only occurs with scopes being empty.

Do you mean the emitting of stateObservable when there is no reason to?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean the emitting of stateObservable when there is no reason to?

yes, exactly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Increment the patch version when merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants