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
52 changes: 52 additions & 0 deletions packages/vtable/__tests__/listTable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,58 @@ describe('listTable init test', () => {
]);
expect(listTable.getScrollTop()).toBe(scrollTop);
});
test('listTable drag select should stop before disabled merged last row', () => {
const dragContainerDom: HTMLElement = createDiv();
dragContainerDom.style.position = 'relative';
dragContainerDom.style.width = '800px';
dragContainerDom.style.height = '600px';
const dragRecords = [
{ a: 'r1', b: 1, c: 'x' },
{ a: 'r2', b: 2, c: 'y' },
{ a: 'r3', b: 3, c: 'z' },
{ a: 'r4', b: 4, c: 'w' }
];
const dragTable = new ListTable({
container: dragContainerDom,
columns: [
{ field: 'a', title: 'A', width: 120 },
{ field: 'b', title: 'B', width: 120 },
{ field: 'c', title: 'C', width: 120 }
],
records: dragRecords,
bottomFrozenRowCount: 1,
select: {
disableSelect: (col, row, table) => row === table.rowCount - 1
},
customMergeCell: (col, row, table) => {
if (row === table.rowCount - 1) {
return {
text: 'summary',
range: {
start: { col: 0, row: table.rowCount - 1 },
end: { col: table.colCount - 1, row: table.rowCount - 1 }
}
};
}
}
});

dragTable.stateManager.updateSelectPos(1, 2, false, false, false, false, false);
dragTable.stateManager.updateInteractionState('grabing');
dragTable.stateManager.updateSelectPos(1, dragTable.rowCount - 2, false, false, false, false, false);
dragTable.stateManager.updateSelectPos(1, dragTable.rowCount - 1, false, false, false, false, false);
dragTable.stateManager.endSelectCells(false, false);
dragTable.stateManager.updateInteractionState('default');

expect(dragTable.getSelectedCellRanges()).toEqual([
{
start: { col: 1, row: 2 },
end: { col: 1, row: dragTable.rowCount - 2 }
}
]);

dragTable.release();
});
test('listTable measureTextWidth', () => {
const measureTextWdith = listTable.measureText("家里方大化工撒个福建师大看哈 fdsfgj! *-+&5%#.,'.,。、", {
fontFamily: 'Arial',
Expand Down
2 changes: 2 additions & 0 deletions packages/vtable/examples/list-analysis/list-aggregation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ export function createTable() {
field: 'salary',
title: 'salary',
width: 100,
disableHeaderSelect: true,
disableSelect: true,
aggregation: [
{
aggregationType: AggregationType.MAX,
Expand Down
3 changes: 3 additions & 0 deletions packages/vtable/src/event/listener/container-dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,9 @@ export function bindContainerDomListener(eventManager: EventManager) {
const targetCol = table.getTargetColAtConsiderRightFrozen(selectX, considerFrozenX);
const targetRow = table.getTargetRowAtConsiderBottomFrozen(selectY, considerFrozenY);
if (!table.options.select?.disableDragSelect && isValid(targetCol) && isValid(targetRow)) {
if (isCellDisableSelect(table, targetCol.col, targetRow.row)) {
return;
}
table.stateManager.updateSelectPos(
table.stateManager.select.selectInline === 'row' ? table.colCount - 1 : targetCol.col,
table.stateManager.select.selectInline === 'col' ? table.rowCount - 1 : targetRow.row,
Expand Down
5 changes: 5 additions & 0 deletions packages/vtable/src/state/select/update-position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { Scenegraph } from '../../scenegraph/scenegraph';
import type { SelectAllOnCtrlAOption } from '../../ts-types';
import { InteractionState } from '../../ts-types';
import type { StateManager } from '../state';
import { isCellDisableSelect } from './is-cell-select-highlight';
/**
* @description: 更新select位置
* @param {StateManager} state
Expand Down Expand Up @@ -350,6 +351,10 @@ export function updateSelectPosition(
(interactionState === InteractionState.grabing || table.eventManager.isDraging) &&
!table.stateManager.isResizeCol()
) {
if (col >= 0 && row >= 0 && isCellDisableSelect(table, col, row)) {
scenegraph.updateNextFrame();
return;
}
let extendSelectRange = isValid(skipBodyMerge) ? !skipBodyMerge : true;
// 可能有cellPosStart从-1开始grabing的情况
if (cellPos.col === -1) {
Expand Down
Loading