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
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@visactor/vtable-plugins",
"comment": "Fix an issue where `AddRowColumnPlugin.release()` threw when only row or column controls were enabled (GitHub #5140)",
"type": "patch"
}
],
"packageName": "@visactor/vtable-plugins",
"email": "892739385@qq.com"
}
47 changes: 47 additions & 0 deletions packages/vtable-plugins/__tests__/add-row-column-plugin.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// @ts-nocheck
import { ListTable } from '@visactor/vtable';
import { AddRowColumnPlugin } from '../src';
import { createDiv } from '../../vtable/__tests__/dom';

global.__VERSION__ = 'none';

describe('AddRowColumnPlugin release - issue #5140', () => {
const columns = [
{ field: 'id', title: 'ID', width: 120 },
{ field: 'name', title: 'Name', width: 160 }
];
const records = [
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' }
];

function createTable(pluginOptions) {
const container = createDiv();
container.style.position = 'relative';
container.style.width = '600px';
container.style.height = '400px';

return new ListTable({
container,
columns,
records,
plugins: [new AddRowColumnPlugin(pluginOptions)]
});
}

afterEach(() => {
document.body.innerHTML = '';
});

test('release should not throw when row controls are disabled', () => {
const table = createTable({ addRowEnable: false });

expect(() => table.release()).not.toThrow();
});

test('release should not throw when column controls are disabled', () => {
const table = createTable({ addColumnEnable: false });

expect(() => table.release()).not.toThrow();
});
});
16 changes: 8 additions & 8 deletions packages/vtable-plugins/src/add-row-column.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,13 +457,13 @@ export class AddRowColumnPlugin implements pluginsDefinition.IVTablePlugin {
}
// #endregion
release() {
this.leftDotForAddColumn.remove();
this.rightDotForAddColumn.remove();
this.addIconForAddColumn.remove();
this.addLineForAddColumn.remove();
this.topDotForAddRow.remove();
this.bottomDotForAddRow.remove();
this.addIconForAddRow.remove();
this.addLineForAddRow.remove();
this.leftDotForAddColumn?.remove();
this.rightDotForAddColumn?.remove();
this.addIconForAddColumn?.remove();
this.addLineForAddColumn?.remove();
this.topDotForAddRow?.remove();
this.bottomDotForAddRow?.remove();
this.addIconForAddRow?.remove();
this.addLineForAddRow?.remove();
}
}
Loading