diff --git a/CHANGELOG.md b/CHANGELOG.md
index bbb49c76e..9ecb99df4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
+## [Unreleased]
+
+### Fixed
+
+- Fixed issue where resizing threw an error if no rows were available.
+
## [2.2.0] - 2025-08-19
### Added
diff --git a/dev/vscode-table/resize-empty-table.html b/dev/vscode-table/resize-empty-table.html
new file mode 100644
index 000000000..d5270daad
--- /dev/null
+++ b/dev/vscode-table/resize-empty-table.html
@@ -0,0 +1,42 @@
+
+
+
+
+
+ VSCode Elements
+
+
+
+
+
+
+
+
Component demo
+
+
+
+
+ Col 1
+ Col 2
+
+
+ no data
+
+
+
+
+
+
diff --git a/src/vscode-table/vscode-table.test.ts b/src/vscode-table/vscode-table.test.ts
index 5659533c5..4dcd12ab5 100644
--- a/src/vscode-table/vscode-table.test.ts
+++ b/src/vscode-table/vscode-table.test.ts
@@ -1,5 +1,6 @@
+import {$, dragElement} from '../includes/test-helpers.js';
import {VscodeTable} from './index.js';
-import {expect} from '@open-wc/testing';
+import {expect, fixture, html} from '@open-wc/testing';
describe('vscode-table', () => {
it('is defined', () => {
@@ -13,4 +14,24 @@ describe('vscode-table', () => {
expect(() => el.remove()).not.to.throw();
});
+
+ it('should not throw on resize when no rows are present', async () => {
+ const el = await fixture(html`
+
+
+ Col 1
+ Col 2
+
+
+ no data
+
+
+ `);
+
+ async function testDrag() {
+ await dragElement($(el.shadowRoot!, '.sash-clickable'), 20);
+ }
+
+ expect(await testDrag()).not.to.throw;
+ });
});
diff --git a/src/vscode-table/vscode-table.ts b/src/vscode-table/vscode-table.ts
index 7819c2ef6..c8ffa308a 100644
--- a/src/vscode-table/vscode-table.ts
+++ b/src/vscode-table/vscode-table.ts
@@ -602,7 +602,7 @@ export class VscodeTable extends VscElement {
this._headerCellsToResize[1].style.width = nextColCss;
}
- if (resizeBodyCells) {
+ if (resizeBodyCells && this._cellsToResize[0]) {
this._cellsToResize[0].style.width = prevColCss;
if (this._cellsToResize[1]) {