[v10.1.x] Geomap: Fix tooltip field name regression (#75926)

Geomap: Fix tooltip field name regression (#75511)

(cherry picked from commit 7875dbc6eb)
This commit is contained in:
Nathan Marrs
2023-10-04 16:26:30 -07:00
committed by GitHub
parent d6c3bffe88
commit 19ceb927b1
3 changed files with 12 additions and 2 deletions
@@ -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('getFrameDisplayName', () => {
it('Should return frame name if set', () => {
const frame = toDataFrame({
@@ -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';
@@ -162,7 +164,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) {
@@ -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,