Kibana 7.6: set uiState doesn't seems to work

Hello everybody,

I'm working in the migration of a visualization for Kibana 7.6.0.

This visualization use the AngularVisController.
I use the function uiStateVal from the scope to make some changes on my visualization.

This function works well in the editor mode but not in the dashboard mode.
I noticed that if I comment the following line (line 126 from file src/plugins/embeddable/public/lib/embeddables/embeddable.tsx ) everythings works well :

this.parent.updateInputForChild<TEmbeddableInput>(this.id, changes);

Do you have any clue to help me ?

Also, the update of uiState doesn't call the requestHandler anymore. I have to emit an update state to call the handler as expected.

Heya @pchakour,

You mentioned you are upgrading to 7.6 -- what version are you upgrading from?

Out of curiosity, is the plugin you are working on in a public repository somewhere so that I'd be able to install it and test a few things out?

We've been updating the custom visualization infrastructure quite a bit over 7.x, so I want to make sure there aren't regressions that we have somehow missed, or release notes that are inaccurate.

I'm migrating from 7.5.4.

Unfortunately, the repository is private and not accessible.
However, I did a sample plugin using the legacy interface to reproduce the issues with uiState.

This plugin is accessible here : https://github.com/pchakour/kibanaUiStateIssues

To sum up, I had three issues with uiState. The first one was already here in 7.5.4, you can see my post about this issue : Empty uiState in a custom request handler. I found a workaround by getting the uiState directly in the rootScope.
The second, is that the request handler is doesn't call anymore after an uiState modification. And the last one is about the differences of behavior between editor mode and dashboard mode.

My sample plugin try to show these three issues...

@lukeelmers did you have time to try my little plugin ?

I try something very simple in the angular controller of the visualization:

$scope.uiState.set('testUiState', 'test');
console.log($scope.uiState.get('testUiState'));

The result of the console log is null.
In the URL, I can found my parameter 'testUiState' but also with a null value.

I don't understand, I'm going to cry :sob:

Hey @pchakour,

Sorry to keep you waiting on this! We've been in the process of migrating large chunks of our visualization infrastructure to the new Kibana platform, which has meant a lot of churn in our vis APIs over 7.x releases. In fact, we've temporarily removed our vis documentation to help prevent confusion as these changes are made. All of this makes issues like these particularly hard to isolate.

Thanks for taking the time to post some example code; it was incredibly helpful in illustrating the issue you are hitting. Since you raised the problem of the uiState in a custom request handler in a separate thread, I'll focus on the issue you have brought up here, which is that calling uiState.set followed by uiState.get returns a null value.

After digging into your example code, I think you've uncovered a bug that we'll need to investigate further. What is happening is that the uiState is getting set correctly, but then immediately afterwards is reset. This occurs in visualize_embeddable.ts, specifically the transferCustomizationsToUiState method. When that method is called with no appState, it clears all of the keys in the uiState, triggering a change event which fires updateInput on the embeddable.

And if that embeddable has this.parent set, it will update the inputs for each of the children... This is why commenting out updateInputForChild "fixes" the problem you are seeing, but of course is not a way we will be able to address this since it would break other vis embeddables.

I hope this helps explain the problem a bit... unfortunately we need to have further discussions around what the right solution should be. I've created an issue to track this in more detail if you'd like to follow along: https://github.com/elastic/kibana/issues/60162

Cheers,

Luke

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.