Skip to content

[Lens] Fix palette switching on Partition charts#228051

Merged
nickofthyme merged 3 commits intoelastic:mainfrom
nickofthyme:fix-palette-pie-charts
Jul 16, 2025
Merged

[Lens] Fix palette switching on Partition charts#228051
nickofthyme merged 3 commits intoelastic:mainfrom
nickofthyme:fix-palette-pie-charts

Conversation

@nickofthyme
Copy link
Contributor

@nickofthyme nickofthyme commented Jul 15, 2025

Summary

Fixes issue in Lens Partition chart which prevented the user from switching legacy palettes.

Zight.Recording.2025-07-15.at.10.00.38.AM.mp4

Fixes #227922

Details

The issue here was that we are using useDebouncedValue which sets the value async. When the user selects a legacy palette we call setLocalState to set the palette then immediately call setColorMapping which was overriding the palette changes.

Really we just need to clear the colorMapping when a palette is set. Instead of doing this every time the palette is set, I added the onModeChange callback to clear the colorMapping once when the mode is set to legacy.

Checklist

Release Notes

Fixes an issue where a Lens Partition chart (i.e. Pie) prevented the user from selecting a legacy palette.

@nickofthyme nickofthyme added Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// Feature:Lens release_note:fix backport:version Backport to applied version labels v9.1.0 v8.19.0 v9.2.0 labels Jul 15, 2025
@nickofthyme nickofthyme marked this pull request as ready for review July 15, 2025 15:34
@nickofthyme nickofthyme requested a review from a team as a code owner July 15, 2025 15:34
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-visualizations (Team:Visualizations)

@nickofthyme nickofthyme requested a review from andrimal July 15, 2025 15:34
@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 +32.0B
Copy link
Contributor

@andrimal andrimal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally and the issue is fixed 🚀

@nickofthyme nickofthyme merged commit 3cd7dec into elastic:main Jul 16, 2025
12 checks passed
@nickofthyme nickofthyme deleted the fix-palette-pie-charts branch July 16, 2025 14:48
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.19, 9.1

https://github.com/elastic/kibana/actions/runs/16322769353

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 16, 2025
## Summary

Fixes issue in Lens Partition chart which prevented the user from
switching legacy palettes.

https://github.com/user-attachments/assets/1cc3d222-f823-4135-9fde-257b75ebfbe0

Fixes elastic#227922

## Details

The issue here was that we are using `useDebouncedValue` which sets the
value async. When the user selects a legacy palette we call
`setLocalState` to set the palette then immediately call
`setColorMapping` which was overriding the palette changes.

Really we just need to clear the `colorMapping` when a `palette` is set.
Instead of doing this every time the palette is set, I added the
`onModeChange` callback to clear the `colorMapping` once when the mode
is set to legacy.

## Checklist

- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

## Release Notes

Fixes an issue where a Lens Partition chart (i.e. `Pie`) prevented the
user from selecting a legacy palette.

(cherry picked from commit 3cd7dec)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 16, 2025
## Summary

Fixes issue in Lens Partition chart which prevented the user from
switching legacy palettes.

https://github.com/user-attachments/assets/1cc3d222-f823-4135-9fde-257b75ebfbe0

Fixes elastic#227922

## Details

The issue here was that we are using `useDebouncedValue` which sets the
value async. When the user selects a legacy palette we call
`setLocalState` to set the palette then immediately call
`setColorMapping` which was overriding the palette changes.

Really we just need to clear the `colorMapping` when a `palette` is set.
Instead of doing this every time the palette is set, I added the
`onModeChange` callback to clear the `colorMapping` once when the mode
is set to legacy.

## Checklist

- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

## Release Notes

Fixes an issue where a Lens Partition chart (i.e. `Pie`) prevented the
user from selecting a legacy palette.

(cherry picked from commit 3cd7dec)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.19
9.1

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Jul 16, 2025
…8242)

# Backport

This will backport the following commits from `main` to `9.1`:
- [[Lens] Fix palette switching on Partition charts
(#228051)](#228051)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Nick
Partridge","email":"nicholas.partridge@elastic.co"},"sourceCommit":{"committedDate":"2025-07-16T14:48:27Z","message":"[Lens]
Fix palette switching on Partition charts (#228051)\n\n##
Summary\n\nFixes issue in Lens Partition chart which prevented the user
from\nswitching legacy
palettes.\n\n\nhttps://github.com/user-attachments/assets/1cc3d222-f823-4135-9fde-257b75ebfbe0\n\nFixes
#227922\n\n## Details\n\nThe issue here was that we are using
`useDebouncedValue` which sets the\nvalue async. When the user selects a
legacy palette we call\n`setLocalState` to set the palette then
immediately call\n`setColorMapping` which was overriding the palette
changes.\n\nReally we just need to clear the `colorMapping` when a
`palette` is set.\nInstead of doing this every time the palette is set,
I added the\n`onModeChange` callback to clear the `colorMapping` once
when the mode\nis set to legacy.\n\n## Checklist\n\n- [ ] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [ ] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n## Release Notes\n\nFixes an
issue where a Lens Partition chart (i.e. `Pie`) prevented the\nuser from
selecting a legacy
palette.","sha":"3cd7dec0edb9c761acb7409dfda5edd4b0f66c23","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Visualizations","Feature:Lens","backport:version","v9.1.0","v8.19.0","v9.2.0"],"title":"[Lens]
Fix palette switching on Partition
charts","number":228051,"url":"https://github.com/elastic/kibana/pull/228051","mergeCommit":{"message":"[Lens]
Fix palette switching on Partition charts (#228051)\n\n##
Summary\n\nFixes issue in Lens Partition chart which prevented the user
from\nswitching legacy
palettes.\n\n\nhttps://github.com/user-attachments/assets/1cc3d222-f823-4135-9fde-257b75ebfbe0\n\nFixes
#227922\n\n## Details\n\nThe issue here was that we are using
`useDebouncedValue` which sets the\nvalue async. When the user selects a
legacy palette we call\n`setLocalState` to set the palette then
immediately call\n`setColorMapping` which was overriding the palette
changes.\n\nReally we just need to clear the `colorMapping` when a
`palette` is set.\nInstead of doing this every time the palette is set,
I added the\n`onModeChange` callback to clear the `colorMapping` once
when the mode\nis set to legacy.\n\n## Checklist\n\n- [ ] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [ ] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n## Release Notes\n\nFixes an
issue where a Lens Partition chart (i.e. `Pie`) prevented the\nuser from
selecting a legacy
palette.","sha":"3cd7dec0edb9c761acb7409dfda5edd4b0f66c23"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/228051","number":228051,"mergeCommit":{"message":"[Lens]
Fix palette switching on Partition charts (#228051)\n\n##
Summary\n\nFixes issue in Lens Partition chart which prevented the user
from\nswitching legacy
palettes.\n\n\nhttps://github.com/user-attachments/assets/1cc3d222-f823-4135-9fde-257b75ebfbe0\n\nFixes
#227922\n\n## Details\n\nThe issue here was that we are using
`useDebouncedValue` which sets the\nvalue async. When the user selects a
legacy palette we call\n`setLocalState` to set the palette then
immediately call\n`setColorMapping` which was overriding the palette
changes.\n\nReally we just need to clear the `colorMapping` when a
`palette` is set.\nInstead of doing this every time the palette is set,
I added the\n`onModeChange` callback to clear the `colorMapping` once
when the mode\nis set to legacy.\n\n## Checklist\n\n- [ ] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [ ] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n## Release Notes\n\nFixes an
issue where a Lens Partition chart (i.e. `Pie`) prevented the\nuser from
selecting a legacy
palette.","sha":"3cd7dec0edb9c761acb7409dfda5edd4b0f66c23"}}]}]
BACKPORT-->

Co-authored-by: Nick Partridge <nicholas.partridge@elastic.co>
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Jul 18, 2025
@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.
cc: @nickofthyme

1 similar comment
@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.
cc: @nickofthyme

Bluefinger pushed a commit to Bluefinger/kibana that referenced this pull request Jul 22, 2025
## Summary

Fixes issue in Lens Partition chart which prevented the user from
switching legacy palettes.


https://github.com/user-attachments/assets/1cc3d222-f823-4135-9fde-257b75ebfbe0

Fixes elastic#227922

## Details

The issue here was that we are using `useDebouncedValue` which sets the
value async. When the user selects a legacy palette we call
`setLocalState` to set the palette then immediately call
`setColorMapping` which was overriding the palette changes.

Really we just need to clear the `colorMapping` when a `palette` is set.
Instead of doing this every time the palette is set, I added the
`onModeChange` callback to clear the `colorMapping` once when the mode
is set to legacy.

## Checklist

- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

## Release Notes

Fixes an issue where a Lens Partition chart (i.e. `Pie`) prevented the
user from selecting a legacy palette.
@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.
cc: @nickofthyme

@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.
cc: @nickofthyme

kibanamachine added a commit that referenced this pull request Jul 23, 2025
…28241)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Lens] Fix palette switching on Partition charts
(#228051)](#228051)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Nick
Partridge","email":"nicholas.partridge@elastic.co"},"sourceCommit":{"committedDate":"2025-07-16T14:48:27Z","message":"[Lens]
Fix palette switching on Partition charts (#228051)\n\n##
Summary\n\nFixes issue in Lens Partition chart which prevented the user
from\nswitching legacy
palettes.\n\n\nhttps://github.com/user-attachments/assets/1cc3d222-f823-4135-9fde-257b75ebfbe0\n\nFixes
#227922\n\n## Details\n\nThe issue here was that we are using
`useDebouncedValue` which sets the\nvalue async. When the user selects a
legacy palette we call\n`setLocalState` to set the palette then
immediately call\n`setColorMapping` which was overriding the palette
changes.\n\nReally we just need to clear the `colorMapping` when a
`palette` is set.\nInstead of doing this every time the palette is set,
I added the\n`onModeChange` callback to clear the `colorMapping` once
when the mode\nis set to legacy.\n\n## Checklist\n\n- [ ] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [ ] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n## Release Notes\n\nFixes an
issue where a Lens Partition chart (i.e. `Pie`) prevented the\nuser from
selecting a legacy
palette.","sha":"3cd7dec0edb9c761acb7409dfda5edd4b0f66c23","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Visualizations","Feature:Lens","backport:version","v9.1.0","v8.19.0","v9.2.0"],"title":"[Lens]
Fix palette switching on Partition
charts","number":228051,"url":"https://github.com/elastic/kibana/pull/228051","mergeCommit":{"message":"[Lens]
Fix palette switching on Partition charts (#228051)\n\n##
Summary\n\nFixes issue in Lens Partition chart which prevented the user
from\nswitching legacy
palettes.\n\n\nhttps://github.com/user-attachments/assets/1cc3d222-f823-4135-9fde-257b75ebfbe0\n\nFixes
#227922\n\n## Details\n\nThe issue here was that we are using
`useDebouncedValue` which sets the\nvalue async. When the user selects a
legacy palette we call\n`setLocalState` to set the palette then
immediately call\n`setColorMapping` which was overriding the palette
changes.\n\nReally we just need to clear the `colorMapping` when a
`palette` is set.\nInstead of doing this every time the palette is set,
I added the\n`onModeChange` callback to clear the `colorMapping` once
when the mode\nis set to legacy.\n\n## Checklist\n\n- [ ] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [ ] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n## Release Notes\n\nFixes an
issue where a Lens Partition chart (i.e. `Pie`) prevented the\nuser from
selecting a legacy
palette.","sha":"3cd7dec0edb9c761acb7409dfda5edd4b0f66c23"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/228051","number":228051,"mergeCommit":{"message":"[Lens]
Fix palette switching on Partition charts (#228051)\n\n##
Summary\n\nFixes issue in Lens Partition chart which prevented the user
from\nswitching legacy
palettes.\n\n\nhttps://github.com/user-attachments/assets/1cc3d222-f823-4135-9fde-257b75ebfbe0\n\nFixes
#227922\n\n## Details\n\nThe issue here was that we are using
`useDebouncedValue` which sets the\nvalue async. When the user selects a
legacy palette we call\n`setLocalState` to set the palette then
immediately call\n`setColorMapping` which was overriding the palette
changes.\n\nReally we just need to clear the `colorMapping` when a
`palette` is set.\nInstead of doing this every time the palette is set,
I added the\n`onModeChange` callback to clear the `colorMapping` once
when the mode\nis set to legacy.\n\n## Checklist\n\n- [ ] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [ ] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n## Release Notes\n\nFixes an
issue where a Lens Partition chart (i.e. `Pie`) prevented the\nuser from
selecting a legacy
palette.","sha":"3cd7dec0edb9c761acb7409dfda5edd4b0f66c23"}}]}]
BACKPORT-->

Co-authored-by: Nick Partridge <nicholas.partridge@elastic.co>
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Jul 23, 2025
kertal pushed a commit to kertal/kibana that referenced this pull request Jul 25, 2025
## Summary

Fixes issue in Lens Partition chart which prevented the user from
switching legacy palettes.


https://github.com/user-attachments/assets/1cc3d222-f823-4135-9fde-257b75ebfbe0

Fixes elastic#227922

## Details

The issue here was that we are using `useDebouncedValue` which sets the
value async. When the user selects a legacy palette we call
`setLocalState` to set the palette then immediately call
`setColorMapping` which was overriding the palette changes.

Really we just need to clear the `colorMapping` when a `palette` is set.
Instead of doing this every time the palette is set, I added the
`onModeChange` callback to clear the `colorMapping` once when the mode
is set to legacy.

## Checklist

- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

## Release Notes

Fixes an issue where a Lens Partition chart (i.e. `Pie`) prevented the
user from selecting a legacy palette.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels Feature:Lens release_note:fix Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// v8.19.0 v9.1.0 v9.2.0

4 participants