[Input Controls] Fix Resize Resetting Selections#76573
[Input Controls] Fix Resize Resetting Selections#76573ThomThomson merged 9 commits intoelastic:masterfrom
Conversation
ThomThomson
left a comment
There was a problem hiding this comment.
Open question:
Usage of isEqual here may be inefficient and better replaced with a custom diff.
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.
sulemanof
left a comment
There was a problem hiding this comment.
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.
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.
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.
sulemanof
left a comment
There was a problem hiding this comment.
LGTM!
Checked locally, everything works as expected.
majagrubic
left a comment
There was a problem hiding this comment.
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