-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UrlSync: Variable changes adds browser history steps #882
base: main
Are you sure you want to change the base?
Conversation
@@ -428,6 +446,16 @@ export class MultiValueUrlSyncHandler<TState extends MultiValueVariableState = M | |||
this._sceneObject.changeValueTo(urlValue); | |||
} | |||
} | |||
|
|||
public performBrowserHistoryAction(callback: () => void) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! 🎉 Do you think it could be the default behavior of SceneObjectUrlSyncConfig
and AdHocFiltersVariableUrlSyncHandler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, probably. pushed an update to #878 that adds it to SceneObjectUrlSyncConfig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love this change! Left only one comment with a proposal but would also be happy if it's merged as is.
); | ||
}} | ||
onChange={(newValue, action) => { | ||
if (action.action === 'clear' && noValueOnClear) { | ||
model.changeValueTo([]); | ||
model.changeValueTo([], undefined, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to add an extra method to avoid repeatedly calling the changeValueTo
method with undefined
and true
?
For example:
- variable.changeValueTo(value, undefined, true);
+ variable.changeValuePushToHistory(value);
+
+ public changeValuePushToHistory(value: VariableValue) {
+ this.changeValueTo(value, undefined, true);
+ }
It's just some syntactic sugar, but will make it easier to read in the plugin code. Alternatively each plugin can also implement their own util to handle this changeVariablePushToHistory(variable, value)
if we don't want to add it to the library.
This works on top of #878
and explores adding browser history steps for variables.
Works surprisingly well. The challenge here is that not all variable value changes should create URL history steps.
Given a valid state of datacenter=US , cluster=US-1
To solve this we need to differentiate between variable changes that are due to user actions and those that come due to parent variable change. which is why I am adding isUserAction bool to changeValueTo
works surprisingly well