Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(module: table): resizable table with ScrollY #3746

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions components/core/JsInterop/modules/components/tableHelper.ts
Expand Up @@ -18,7 +18,7 @@
window.addEventListener('resize', bodyRef.bindScroll);

if (resizable) {
tableHelper.enableColumnResizing(tableRef);
tableHelper.enableColumnResizing(headerRef, tableRef, scrollY);

Check warning on line 21 in components/core/JsInterop/modules/components/tableHelper.ts

View check run for this annotation

Codecov / codecov/patch

components/core/JsInterop/modules/components/tableHelper.ts#L21

Added line #L21 was not covered by tests
}
}

Expand Down Expand Up @@ -59,13 +59,18 @@
pingRight ? wrapperRef.classList.add("ant-table-ping-right") : wrapperRef.classList.remove("ant-table-ping-right");
}

static enableColumnResizing(tableElement) {
static enableColumnResizing(headerElement, tableElement, scrollY) {

Check warning on line 62 in components/core/JsInterop/modules/components/tableHelper.ts

View check run for this annotation

Codecov / codecov/patch

components/core/JsInterop/modules/components/tableHelper.ts#L62

Added line #L62 was not covered by tests

const cols = tableElement.querySelectorAll('col');
const ths = scrollY ?
headerElement.querySelectorAll('.ant-table-thead th') :
tableElement.tHead.querySelectorAll('.ant-table-thead th');
const headerCols = scrollY ? headerElement.querySelectorAll('col') : null;

tableElement.tHead.querySelectorAll('.ant-table-thead th').forEach((th, i) => {
ths.forEach((th, i) => {

Check warning on line 70 in components/core/JsInterop/modules/components/tableHelper.ts

View check run for this annotation

Codecov / codecov/patch

components/core/JsInterop/modules/components/tableHelper.ts#L70

Added line #L70 was not covered by tests

const col = cols[i];
const headerCol = headerCols ? headerCols[i] : null;
const handle = document.createElement('div');
handle.classList.add('ant-table-resizable-handle');
handle.style.height = `${tableElement.offsetHeight}px`;
Expand Down Expand Up @@ -104,6 +109,9 @@
if (updatedColumnWidth > 0) {
th.style.width = `${updatedColumnWidth}px`;
col.style.width = `${updatedColumnWidth}px`;
if (headerCol) {
headerCol.style.width =`${updatedColumnWidth}px`;

Check warning on line 113 in components/core/JsInterop/modules/components/tableHelper.ts

View check run for this annotation

Codecov / codecov/patch

components/core/JsInterop/modules/components/tableHelper.ts#L113

Added line #L113 was not covered by tests
}
handle.style.right = '0';
handle.style.left = '';
handle.classList.remove('ant-table-resizing');
Expand Down