# Kibana 7.6: set uiState doesn't seems to work

**URL:** <https://discuss.elastic.co/t/kibana-7-6-set-uistate-doesnt-seems-to-work/219844>\
**Category:** Kibana\
**Created:** [February 18, 2020, 6:27pm UTC](https://discuss.elastic.co/t/kibana-7-6-set-uistate-doesnt-seems-to-work/219844 "2020-02-18T18:27:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pchakour](https://avatars.discourse-cdn.com/v4/letter/p/e36b37/32.png) [@pchakour](https://discuss.elastic.co/u/pchakour)\
**Post date:** [February 18, 2020, 6:27pm UTC](https://discuss.elastic.co/t/kibana-7-6-set-uistate-doesnt-seems-to-work/219844/1 "2020-02-18T18:27:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lukeelmers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukeelmers/32/35230_2.png) [@lukeelmers](https://discuss.elastic.co/u/lukeelmers)\
**Post date:** [February 18, 2020, 8:56pm UTC](https://discuss.elastic.co/t/kibana-7-6-set-uistate-doesnt-seems-to-work/219844/2 "2020-02-18T20:56:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pchakour](https://avatars.discourse-cdn.com/v4/letter/p/e36b37/32.png) [@pchakour](https://discuss.elastic.co/u/pchakour)\
**Post date:** [February 19, 2020, 11:20am UTC](https://discuss.elastic.co/t/kibana-7-6-set-uistate-doesnt-seems-to-work/219844/3 "2020-02-19T11:20:17Z")

</div>

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](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](https://discuss.elastic.co/t/empty-uistate-in-a-custom-request-handler/214645). 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...

---

<div class="post-metadata">

**Author:** ![pchakour](https://avatars.discourse-cdn.com/v4/letter/p/e36b37/32.png) [@pchakour](https://discuss.elastic.co/u/pchakour)\
**Post date:** [February 21, 2020, 7:54am UTC](https://discuss.elastic.co/t/kibana-7-6-set-uistate-doesnt-seems-to-work/219844/4 "2020-02-21T07:54:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pchakour](https://avatars.discourse-cdn.com/v4/letter/p/e36b37/32.png) [@pchakour](https://discuss.elastic.co/u/pchakour)\
**Post date:** [February 28, 2020, 5:20pm UTC](https://discuss.elastic.co/t/kibana-7-6-set-uistate-doesnt-seems-to-work/219844/5 "2020-02-28T17:20:21Z")

</div>

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 😭

---

<div class="post-metadata">

**Author:** ![lukeelmers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukeelmers/32/35230_2.png) [@lukeelmers](https://discuss.elastic.co/u/lukeelmers)\
**Post date:** [March 13, 2020, 8:47pm UTC](https://discuss.elastic.co/t/kibana-7-6-set-uistate-doesnt-seems-to-work/219844/6 "2020-03-13T20:47:49Z")

</div>

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](https://www.elastic.co/guide/en/kibana/current/development-visualize-index.html) 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](https://github.com/elastic/kibana/blob/ba5784ac57c4145f642f35e1e1f77d93944cd022/src/legacy/core_plugins/visualizations/public/np_ready/public/embeddable/visualize_embeddable.ts#L179-L199). When that method is called with no `appState`, it [clears all of the keys in the uiState](https://github.com/elastic/kibana/blob/ba5784ac57c4145f642f35e1e1f77d93944cd022/src/legacy/core_plugins/visualizations/public/np_ready/public/embeddable/visualize_embeddable.ts#L197), 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](https://github.com/elastic/kibana/issues/60162)

Cheers,

Luke

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 10, 2020, 9:00pm UTC](https://discuss.elastic.co/t/kibana-7-6-set-uistate-doesnt-seems-to-work/219844/7 "2020-04-10T21:00:19Z")

</div>

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