Geomap: Fix tooltip field name regression (#75511)

This commit is contained in:
Nathan Marrs 2023-10-03 22:43:12 +02:00 committed by GitHub
parent ad851ea952
commit 7875dbc6eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View File

@ -15,6 +15,11 @@ function checkScenario(scenario: TitleScenario): string {
return getFieldDisplayName(field, frame, scenario.frames);
}
jest.mock('lodash', () => ({
...jest.requireActual('lodash'),
isEqual: jest.fn().mockImplementation((obj1, obj2) => obj1 === obj2),
}));
describe('getFieldDisplayName', () => {
it('Should add suffix for comparison frames', () => {
const frame = toDataFrame({

View File

@ -1,3 +1,5 @@
import { isEqual } from 'lodash';
import { DataFrame, Field, TIME_SERIES_VALUE_FIELD_NAME, FieldType, TIME_SERIES_TIME_FIELD_NAME } from '../types';
import { formatLabels } from '../utils/labels';
@ -165,7 +167,7 @@ function getUniqueFieldName(field: Field, frame?: DataFrame) {
for (let i = 0; i < frame.fields.length; i++) {
const otherField = frame.fields[i];
if (field === otherField) {
if (isEqual(field, otherField)) {
foundSelf = true;
if (dupeCount > 0) {

View File

@ -72,8 +72,11 @@ export const DataHoverView = ({ data, rowIndex, columnIndex, sortOrder, mode, he
});
}
// Sanitize field by removing hovered property to fix unique display name issue
const { hovered, ...sanitizedField } = field;
displayValues.push({
name: getFieldDisplayName(field, data),
name: getFieldDisplayName(sanitizedField, data),
value,
valueString: formattedValueToString(fieldDisplay),
highlight: field.hovered,