Skip to content

[Lens] Forward secondary prefix correctly when state value is an empty string (None option)#228183

Merged
mariairiartef merged 2 commits intoelastic:mainfrom
mariairiartef:fix/227281
Jul 17, 2025
Merged

[Lens] Forward secondary prefix correctly when state value is an empty string (None option)#228183
mariairiartef merged 2 commits intoelastic:mainfrom
mariairiartef:fix/227281

Conversation

@mariairiartef
Copy link
Contributor

@mariairiartef mariairiartef commented Jul 16, 2025

Closes #227281

Summary

When going from state to expression, the secondaryPrefix value wasn't forwarded correctly when the secondaryPrefix state value was an empty string (the empty string is set in the state when the Prefix "None" option is selected in settings). It was forwarded as undefined, causing showing the column name as the prefix on:

const prefix = config.metric.secondaryPrefix ?? metricColumn?.name;

After:

Screen.Recording.2025-07-16.at.12.16.00.mov

Checklist

  • Unit or functional tests were updated or added to match the most common scenarios
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines
  • Review the backport guidelines and apply applicable backport:* labels.
@mariairiartef mariairiartef self-assigned this Jul 16, 2025
@mariairiartef mariairiartef added the bug Fixes for quality problems that affect the customer experience label Jul 16, 2025
@mariairiartef mariairiartef requested a review from a team as a code owner July 16, 2025 10:18
@mariairiartef mariairiartef added release_note:fix Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// Feature:Lens backport:version Backport to applied version labels v9.1.0 v8.19.0 v9.2.0 labels Jul 16, 2025
@elasticmachine
Copy link
Contributor

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

Copy link
Contributor

@markov00 markov00 left a comment

Choose a reason for hiding this comment

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

Thanks, it works fine.
I believe we should improve that "prefix" label in the form to be more a show/hide label/name than prefix. auto doesn't have much sense, because I believe we are not doing anything special there, custom is just an override of the Name, and none is the hide.
There is no need to have 2 different naming, one just for the table output in the inspector and one only used in the visualization.

Could you please open an issue for this improvement? thanks

@mariairiartef
Copy link
Contributor Author

Thanks, it works fine. I believe we should improve that "prefix" label in the form to be more a show/hide label/name than prefix. auto doesn't have much sense, because I believe we are not doing anything special there, custom is just an override of the Name, and none is the hide. There is no need to have 2 different naming, one just for the table output in the inspector and one only used in the visualization.

Could you please open an issue for this improvement? thanks

I believe this will be improved when we add the new version of the metric chart. We will update the Secondary Metric settings and "prefix" won't make sense anymore because we will add the possibility of adding it before or after the value/badge.

@mariairiartef mariairiartef enabled auto-merge (squash) July 17, 2025 09:35
@mariairiartef mariairiartef merged commit d1846d3 into elastic:main Jul 17, 2025
12 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.19, 9.1

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

@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 +11.0B

History

cc @mariairiartef

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 17, 2025
…y string (`None` option) (elastic#228183)

Closes elastic#227281

## Summary

When going from state to expression, the secondaryPrefix value wasn't
forwarded correctly when the secondaryPrefix state value was an empty
string (the empty string is set in the state when the Prefix "None"
option is selected in settings). It was forwarded as `undefined`,
causing showing the column name as the prefix on:

https://github.com/elastic/kibana/blob/2928bdf1cb5f8fd648c6a46a52ae3f96b4b01a70/src/platform/plugins/shared/chart_expressions/expression_metric/public/components/secondary_metric.tsx#L255

#### After:

https://github.com/user-attachments/assets/1a104f9e-bf78-4acc-aca5-a3866c80d03f

### Checklist
- [x] [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
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [x] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

(cherry picked from commit d1846d3)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 17, 2025
…y string (`None` option) (elastic#228183)

Closes elastic#227281

## Summary

When going from state to expression, the secondaryPrefix value wasn't
forwarded correctly when the secondaryPrefix state value was an empty
string (the empty string is set in the state when the Prefix "None"
option is selected in settings). It was forwarded as `undefined`,
causing showing the column name as the prefix on:

https://github.com/elastic/kibana/blob/2928bdf1cb5f8fd648c6a46a52ae3f96b4b01a70/src/platform/plugins/shared/chart_expressions/expression_metric/public/components/secondary_metric.tsx#L255

#### After:

https://github.com/user-attachments/assets/1a104f9e-bf78-4acc-aca5-a3866c80d03f

### Checklist
- [x] [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
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [x] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

(cherry picked from commit d1846d3)
@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 17, 2025
…n empty string (`None` option) (#228183) (#228424)

# Backport

This will backport the following commits from `main` to `9.1`:
- [[Lens] Forward secondary prefix correctly when state value is an
empty string (`None` option)
(#228183)](#228183)

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

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

<!--BACKPORT [{"author":{"name":"Maria
Iriarte","email":"106958839+mariairiartef@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-07-17T10:49:51Z","message":"[Lens]
Forward secondary prefix correctly when state value is an empty string
(`None` option) (#228183)\n\nCloses
https://github.com/elastic/kibana/issues/227281\n\n## Summary\n\nWhen
going from state to expression, the secondaryPrefix value
wasn't\nforwarded correctly when the secondaryPrefix state value was an
empty\nstring (the empty string is set in the state when the Prefix
\"None\"\noption is selected in settings). It was forwarded as
`undefined`,\ncausing showing the column name as the prefix
on:\n\n\nhttps://github.com/elastic/kibana/blob/2928bdf1cb5f8fd648c6a46a52ae3f96b4b01a70/src/platform/plugins/shared/chart_expressions/expression_metric/public/components/secondary_metric.tsx#L255\n\n####
After:\n\n\nhttps://github.com/user-attachments/assets/1a104f9e-bf78-4acc-aca5-a3866c80d03f\n\n\n###
Checklist\n- [x] [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- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*`
labels.","sha":"d1846d304a43606f9d3be7e38323e14eb64ef1a6","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:Visualizations","Feature:Lens","backport:version","v9.1.0","v8.19.0","v9.2.0"],"title":"[Lens]
Forward secondary prefix correctly when state value is an empty string
(`None`
option)","number":228183,"url":"https://github.com/elastic/kibana/pull/228183","mergeCommit":{"message":"[Lens]
Forward secondary prefix correctly when state value is an empty string
(`None` option) (#228183)\n\nCloses
https://github.com/elastic/kibana/issues/227281\n\n## Summary\n\nWhen
going from state to expression, the secondaryPrefix value
wasn't\nforwarded correctly when the secondaryPrefix state value was an
empty\nstring (the empty string is set in the state when the Prefix
\"None\"\noption is selected in settings). It was forwarded as
`undefined`,\ncausing showing the column name as the prefix
on:\n\n\nhttps://github.com/elastic/kibana/blob/2928bdf1cb5f8fd648c6a46a52ae3f96b4b01a70/src/platform/plugins/shared/chart_expressions/expression_metric/public/components/secondary_metric.tsx#L255\n\n####
After:\n\n\nhttps://github.com/user-attachments/assets/1a104f9e-bf78-4acc-aca5-a3866c80d03f\n\n\n###
Checklist\n- [x] [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- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*`
labels.","sha":"d1846d304a43606f9d3be7e38323e14eb64ef1a6"}},"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/228183","number":228183,"mergeCommit":{"message":"[Lens]
Forward secondary prefix correctly when state value is an empty string
(`None` option) (#228183)\n\nCloses
https://github.com/elastic/kibana/issues/227281\n\n## Summary\n\nWhen
going from state to expression, the secondaryPrefix value
wasn't\nforwarded correctly when the secondaryPrefix state value was an
empty\nstring (the empty string is set in the state when the Prefix
\"None\"\noption is selected in settings). It was forwarded as
`undefined`,\ncausing showing the column name as the prefix
on:\n\n\nhttps://github.com/elastic/kibana/blob/2928bdf1cb5f8fd648c6a46a52ae3f96b4b01a70/src/platform/plugins/shared/chart_expressions/expression_metric/public/components/secondary_metric.tsx#L255\n\n####
After:\n\n\nhttps://github.com/user-attachments/assets/1a104f9e-bf78-4acc-aca5-a3866c80d03f\n\n\n###
Checklist\n- [x] [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- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*`
labels.","sha":"d1846d304a43606f9d3be7e38323e14eb64ef1a6"}}]}]
BACKPORT-->

Co-authored-by: Maria Iriarte <106958839+mariairiartef@users.noreply.github.com>
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Jul 21, 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: @mariairiartef

kibanamachine added a commit that referenced this pull request Jul 22, 2025
…an empty string (`None` option) (#228183) (#228423)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Lens] Forward secondary prefix correctly when state value is an
empty string (`None` option)
(#228183)](#228183)

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

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

<!--BACKPORT [{"author":{"name":"Maria
Iriarte","email":"106958839+mariairiartef@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-07-17T10:49:51Z","message":"[Lens]
Forward secondary prefix correctly when state value is an empty string
(`None` option) (#228183)\n\nCloses
https://github.com/elastic/kibana/issues/227281\n\n## Summary\n\nWhen
going from state to expression, the secondaryPrefix value
wasn't\nforwarded correctly when the secondaryPrefix state value was an
empty\nstring (the empty string is set in the state when the Prefix
\"None\"\noption is selected in settings). It was forwarded as
`undefined`,\ncausing showing the column name as the prefix
on:\n\n\nhttps://github.com/elastic/kibana/blob/2928bdf1cb5f8fd648c6a46a52ae3f96b4b01a70/src/platform/plugins/shared/chart_expressions/expression_metric/public/components/secondary_metric.tsx#L255\n\n####
After:\n\n\nhttps://github.com/user-attachments/assets/1a104f9e-bf78-4acc-aca5-a3866c80d03f\n\n\n###
Checklist\n- [x] [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- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*`
labels.","sha":"d1846d304a43606f9d3be7e38323e14eb64ef1a6","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:Visualizations","Feature:Lens","backport:version","v9.1.0","v8.19.0","v9.2.0"],"title":"[Lens]
Forward secondary prefix correctly when state value is an empty string
(`None`
option)","number":228183,"url":"https://github.com/elastic/kibana/pull/228183","mergeCommit":{"message":"[Lens]
Forward secondary prefix correctly when state value is an empty string
(`None` option) (#228183)\n\nCloses
https://github.com/elastic/kibana/issues/227281\n\n## Summary\n\nWhen
going from state to expression, the secondaryPrefix value
wasn't\nforwarded correctly when the secondaryPrefix state value was an
empty\nstring (the empty string is set in the state when the Prefix
\"None\"\noption is selected in settings). It was forwarded as
`undefined`,\ncausing showing the column name as the prefix
on:\n\n\nhttps://github.com/elastic/kibana/blob/2928bdf1cb5f8fd648c6a46a52ae3f96b4b01a70/src/platform/plugins/shared/chart_expressions/expression_metric/public/components/secondary_metric.tsx#L255\n\n####
After:\n\n\nhttps://github.com/user-attachments/assets/1a104f9e-bf78-4acc-aca5-a3866c80d03f\n\n\n###
Checklist\n- [x] [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- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*`
labels.","sha":"d1846d304a43606f9d3be7e38323e14eb64ef1a6"}},"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/228183","number":228183,"mergeCommit":{"message":"[Lens]
Forward secondary prefix correctly when state value is an empty string
(`None` option) (#228183)\n\nCloses
https://github.com/elastic/kibana/issues/227281\n\n## Summary\n\nWhen
going from state to expression, the secondaryPrefix value
wasn't\nforwarded correctly when the secondaryPrefix state value was an
empty\nstring (the empty string is set in the state when the Prefix
\"None\"\noption is selected in settings). It was forwarded as
`undefined`,\ncausing showing the column name as the prefix
on:\n\n\nhttps://github.com/elastic/kibana/blob/2928bdf1cb5f8fd648c6a46a52ae3f96b4b01a70/src/platform/plugins/shared/chart_expressions/expression_metric/public/components/secondary_metric.tsx#L255\n\n####
After:\n\n\nhttps://github.com/user-attachments/assets/1a104f9e-bf78-4acc-aca5-a3866c80d03f\n\n\n###
Checklist\n- [x] [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- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*`
labels.","sha":"d1846d304a43606f9d3be7e38323e14eb64ef1a6"}}]}]
BACKPORT-->

Co-authored-by: Maria Iriarte <106958839+mariairiartef@users.noreply.github.com>
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Jul 22, 2025
Bluefinger pushed a commit to Bluefinger/kibana that referenced this pull request Jul 22, 2025
…y string (`None` option) (elastic#228183)

Closes elastic#227281

## Summary

When going from state to expression, the secondaryPrefix value wasn't
forwarded correctly when the secondaryPrefix state value was an empty
string (the empty string is set in the state when the Prefix "None"
option is selected in settings). It was forwarded as `undefined`,
causing showing the column name as the prefix on:


https://github.com/elastic/kibana/blob/2928bdf1cb5f8fd648c6a46a52ae3f96b4b01a70/src/platform/plugins/shared/chart_expressions/expression_metric/public/components/secondary_metric.tsx#L255

#### After:


https://github.com/user-attachments/assets/1a104f9e-bf78-4acc-aca5-a3866c80d03f


### Checklist
- [x] [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
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [x] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.
kertal pushed a commit to kertal/kibana that referenced this pull request Jul 25, 2025
…y string (`None` option) (elastic#228183)

Closes elastic#227281

## Summary

When going from state to expression, the secondaryPrefix value wasn't
forwarded correctly when the secondaryPrefix state value was an empty
string (the empty string is set in the state when the Prefix "None"
option is selected in settings). It was forwarded as `undefined`,
causing showing the column name as the prefix on:


https://github.com/elastic/kibana/blob/2928bdf1cb5f8fd648c6a46a52ae3f96b4b01a70/src/platform/plugins/shared/chart_expressions/expression_metric/public/components/secondary_metric.tsx#L255

#### After:


https://github.com/user-attachments/assets/1a104f9e-bf78-4acc-aca5-a3866c80d03f


### Checklist
- [x] [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
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [x] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.
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 bug Fixes for quality problems that affect the customer experience 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