Skip to content

Commit

Permalink
fix: 明细表linkField失效 (#2007)
Browse files Browse the repository at this point in the history
* fix: 明细表linkField失效

* test: 补充测试用例

Co-authored-by: 沫君 <[email protected]>
  • Loading branch information
lcx-seima and 沫君 authored Dec 20, 2022
1 parent e42cb30 commit 122552b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
26 changes: 26 additions & 0 deletions packages/s2-core/__tests__/spreadsheet/table-sheet-spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { getContainer, getMockData, sleep } from 'tests/util/helpers';
import { get } from 'lodash';
import {
TableSheet,
type S2Options,
type S2DataConfig,
ResizeType,
ColCell,
TableDataCell,
} from '@/index';
import type { PanelScrollGroup } from '@/group/panel-scroll-group';

const data = getMockData(
'../../../s2-react/__tests__/data/tableau-supermarket.csv',
Expand Down Expand Up @@ -209,4 +212,27 @@ describe('TableSheet normal spec', () => {

expect(lastColumnCell.getMeta().width).toBe(199);
});

test('should render link shape', () => {
const s2 = new TableSheet(getContainer(), dataCfg, {
...options,
frozenRowCount: 0,
frozenColCount: 0,
frozenTrailingColCount: 0,
frozenTrailingRowCount: 0,
});
s2.render();

const orderIdDataCell = (
s2.facet.panelGroup.findAllByName(
'panelScrollGroup',
)[0] as PanelScrollGroup
)
.getChildren()
.find((item: TableDataCell) => item.getMeta().valueField === 'order_id');

expect(get(orderIdDataCell, 'linkFieldShape')).toBeDefined();

s2.destroy();
});
});
5 changes: 4 additions & 1 deletion packages/s2-core/src/utils/interaction/link-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ export const checkIsLinkField = (
): boolean => {
return typeof linkFields === 'function'
? linkFields(meta)
: linkFields.some((field) => field === meta.key || field === meta.id);
: linkFields.some(
(field) =>
field === meta.key || field === meta.id || field === meta.valueField,
);
};

1 comment on commit 122552b

@vercel
Copy link

@vercel vercel bot commented on 122552b Dec 20, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

antvis-s2 – ./

antvis-s2-antv-s2.vercel.app
antvis-s2-git-master-antv-s2.vercel.app
antvis-s2.vercel.app

Please sign in to comment.