[8.18] [Lens] Fix filter labels (#211998) (#212286)

# Backport

This will backport the following commits from `main` to `8.18`:
- [[Lens] Fix filter labels
(#211998)](https://github.com/elastic/kibana/pull/211998)

<!--- 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-02-24T17:02:48Z","message":"[Lens]
Fix filter labels (#211998)\n\nFixes issue causing filter labels to
render as `undefined`. Filter labels now display
correctly.","sha":"4a8928d5d44dc1e6363389bc0bd1f20049fa86ec","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","Team:Visualizations","release_note:skip","v9.0.0","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"[Lens]
Fix filter
labels","number":211998,"url":"https://github.com/elastic/kibana/pull/211998","mergeCommit":{"message":"[Lens]
Fix filter labels (#211998)\n\nFixes issue causing filter labels to
render as `undefined`. Filter labels now display
correctly.","sha":"4a8928d5d44dc1e6363389bc0bd1f20049fa86ec"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/211998","number":211998,"mergeCommit":{"message":"[Lens]
Fix filter labels (#211998)\n\nFixes issue causing filter labels to
render as `undefined`. Filter labels now display
correctly.","sha":"4a8928d5d44dc1e6363389bc0bd1f20049fa86ec"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Nick Partridge <nicholas.partridge@elastic.co>
This commit is contained in:
Kibana Machine 2025-02-25 06:15:43 +11:00 committed by GitHub
parent 4552bd4926
commit 29e2b6ad6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View file

@ -51,11 +51,11 @@ export interface FilterContentProps {
}
export function FilterContent({ filter, valueLabel, fieldLabel, hideAlias }: FilterContentProps) {
if (!hideAlias && filter.meta.alias !== null) {
if (!hideAlias && filter.meta.alias != null) {
return (
<>
<Prefix prefix={filter.meta.negate} />
<FilterValue value={`${filter.meta.alias}`} />
<FilterValue value={filter.meta.alias} />
</>
);
}

View file

@ -77,6 +77,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await lens.goToTimeRange();
await retry.try(async () => {
await clickInChart(30, 5); // hardcoded position of bar, depends heavy on data and charts implementation
const filters = await find.allByCssSelector('.euiCheckbox');
expect(filters).length(2);
const [timeFilter, ipFilter] = filters;
expect(await timeFilter.getVisibleText()).to.be(
'@timestamp: Sep 21, 2015 @ 09:00:00.000 to Sep 21, 2015 @ 12:00:00.000'
);
expect(await ipFilter.getVisibleText()).to.be('ip: 97.220.3.248');
await testSubjects.existOrFail('applyFiltersPopoverButton', { timeout: 2500 });
});