Skip to content
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

[8.x] [Lens] Fix switchVisualizationType to use it without layerId (#196295) #196448

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

kibanamachine
Copy link
Contributor

Backport

This will backport the following commits from main to 8.x:

Questions ?

Please refer to the Backport tool documentation

…#196295)

With [PR elastic#187475](https://github.com/elastic/kibana/pull/187475/files)
we introduced a bug, affecting the AI assistant's suggestions API when
switching between different chart types (e.g., from bar to line chart).
This feature relies on the switchVisualizationType method, which was
changed to require a `layerId`. However, the suggestions API does not
provide `layerId`, causing the chart type to not switch as expected.

Solution:
The bug can be resolved by modifying the logic in the
`switchVisualizationType` method. We changed:

```ts
const dataLayer = state.layers.find((l) => l.layerId === layerId);
```

to:

```ts
const dataLayer = state.layers.find((l) => l.layerId === layerId) ?? state.layers[0];
```

This ensures that the suggestions API falls back to the first layer if
no specific layerId is provided.

---------

Co-authored-by: Marco Vettorello <vettorello.marco@gmail.com>
(cherry picked from commit e476220)
@kibanamachine kibanamachine merged commit 9513867 into elastic:8.x Oct 15, 2024
33 checks passed
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
lens 1.5MB 1.5MB +17.0B

cc @mbondyra

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants