Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
run: node common/scripts/install-run-rush.js install --bypass-policy
- name: Build
env:
NODE_OPTIONS: "--max_old_space_size=4096"
run: node common/scripts/install-run-rush.js build -t @visactor/vtable
NODE_OPTIONS: '--max_old_space_size=4096'
run: node common/scripts/install-run-rush.js build -t @visactor/vtable-search
- name: Test
run: node common/scripts/install-run-rush.js test -t @visactor/vtable
run: node common/scripts/install-run-rush.js test -t @visactor/vtable-search
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "fix(vtable-search): search expanded master-detail tables (#5036)",
"type": "patch",
"packageName": "@visactor/vtable-search"
}
],
"packageName": "@visactor/vtable-search",
"email": "biukam.w@gmail.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "fix(vtable): support indexed custom style overlays",
"type": "patch",
"packageName": "@visactor/vtable"
}
],
"packageName": "@visactor/vtable",
"email": "892739385@qq.com"
}
3 changes: 3 additions & 0 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/* eslint-env jest */
/* eslint-disable no-undef */
// @ts-nocheck

import { SearchComponent } from '../src';

function createTable(values: string[][]) {
const arrangements: { col: number; row: number; style: string }[] = [];
const customCellStyleArrangement: { cellPosition: { col: number; row: number }; customStyleId: string }[] = [];
const table = {
options: {
columns: [{ field: 'name' }]
},
rowCount: values.length + 1,
colCount: values[0]?.length ?? 1,
isReleased: false,
isHeader: jest.fn((_col: number, row: number) => row === 0),
getCellValue: jest.fn((col: number, row: number) => (row === 0 ? 'Name' : values[row - 1][col])),
getCellRange: jest.fn((col: number, row: number) => ({
start: { col, row },
end: { col, row }
})),
registerCustomCellStyle: jest.fn(),
hasCustomCellStyle: jest.fn(() => true),
arrangeCustomCellStyle: jest.fn((position: { col: number; row: number }, style: string) => {
if (style) {
arrangements.push({ col: position.col, row: position.row, style });
customCellStyleArrangement.push({ cellPosition: position, customStyleId: style });
}
}),
customCellStylePlugin: {
customCellStyleArrangement,
addCustomCellStyleArrangement: jest.fn((position: { col: number; row: number }, style: string) => {
arrangements.push({ col: position.col, row: position.row, style });
customCellStyleArrangement.push({ cellPosition: position, customStyleId: style });
}),
clearCustomCellStyleArrangement: jest.fn(() => {
arrangements.splice(0, arrangements.length);
customCellStyleArrangement.splice(0, customCellStyleArrangement.length);
})
},
scenegraph: {
updateCellContent: jest.fn(),
updateNextFrame: jest.fn()
},
getBodyVisibleRowRange: jest.fn(() => ({ rowStart: 1, rowEnd: values.length + 1 })),
getBodyVisibleColRange: jest.fn(() => ({ colStart: 0, colEnd: values[0]?.length ?? 1 })),
scrollToCell: jest.fn()
};

return { table, arrangements };
}

test('search includes and highlights values in expanded master-detail tables', () => {
const main = createTable([['Alice']]);
const detail = createTable([['Widget']]);
main.table.internalProps = {
subTableInstances: new Map([[0, detail.table]])
};

const search = new SearchComponent({
table: main.table as any,
autoJump: false
});

const result = search.search('i');

expect(result.results).toHaveLength(2);
expect(detail.arrangements).toEqual([
{
col: 0,
row: 1,
style: '__search_component_highlight'
}
]);
});

test('focus navigation and clear operate on the matching detail table', () => {
const main = createTable([['Alice']]);
const detail = createTable([['Widget']]);
main.table.internalProps = {
subTableInstances: new Map([[0, detail.table]])
};

const search = new SearchComponent({
table: main.table as any,
autoJump: false
});

search.search('i');
search.next();
search.next();

expect(detail.table.customCellStylePlugin.customCellStyleArrangement).toEqual([
{
cellPosition: { col: 0, row: 1 },
customStyleId: '__search_component_focus'
}
]);

search.clear();

expect(detail.table.customCellStylePlugin.customCellStyleArrangement).toHaveLength(0);
});
Loading
Loading