-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Input Controls] Fix Resize Resetting Selections #76573
[Input Controls] Fix Resize Resetting Selections #76573
Conversation
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.
Open question:
Usage of isEqual
here may be inefficient and better replaced with a custom diff.
if (!this.isLoaded || !isEqual(visParams, this.visParams)) { |
It looks like the items that need to be comapred are:
pinFilters
, updateFIltersOnChange
, useTimeFilter
, and the values inside the controls
array, which have many keys that could have changed.
Due to the complexity of the diff required, I figure that isEqual
might be the right choice.
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.
Tested locally and works well, didn't find any regression.
Left some comments to discuss before merging.
this.timeFilterSubscription = deps.data.query.timefilter.timefilter | ||
.getTimeUpdate$() | ||
.subscribe(() => { | ||
if (this.visParams?.useTimeFilter) { | ||
this.isLoaded = false; | ||
} | ||
}); |
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.
I'm not sure do you really need the subscription?
I didn't find the case where do you need to handle this specific parameter.
Could you please clarify this approach? Thnx
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.
This subscription is used to re-initialize the input controls when the 'useTimeFilter' setting is on, and the time filter has changed. This is an expected behaviour of input controls, and was missing after I stopped the 're-initialize everything on each render' behavior.
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.
LGTM!
Checked locally, everything works as expected.
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.
Tested locally in Chrome on Mac OS, works as described. I am not too familiar with input controls code, but the changes seem reasonable to me.
💚 Build SucceededBuild metricspage load bundle size
History
To update your PR or re-run it, just comment with: |
Fixed resizing controls visualization resetting selections
Fixed resizing controls visualization resetting selections
Fixed resizing controls visualization resetting selections
This PR fixes #76142.
Overview
The problem seems to stem from render() getting called on resize in
src/plugins/visualizations/public/components/visualization_chart.tsx
, whereas the input controls visualization seems to assume that render() should fully reset all the controls, and should only be called on startup. src/plugins/input_control_vis/public/vis_controller.tsxIn my research it seems like this problem has been around since 7.7.
The fix is to use a flag to ensure that the initialization only happens once, and subsequent re-renders don't fully re-initialize.
Checklist
Delete any items that are not applicable to this PR.
For maintainers