Skip to content

Commit

Permalink
fix(table): scrollbar style
Browse files Browse the repository at this point in the history
  • Loading branch information
mynetfan committed Jul 4, 2021
1 parent f477843 commit d8c3820
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 2 deletions.
17 changes: 17 additions & 0 deletions src/components/Table/src/hooks/useTableScroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,23 @@ export function useTableScroll(
bodyEl = tableEl.querySelector('.ant-table-body');
}

const hasScrollBarY = bodyEl.scrollHeight > bodyEl.clientHeight;
const hasScrollBarX = bodyEl.scrollWidth > bodyEl.clientWidth;

if (hasScrollBarY) {
tableEl.classList.contains('hide-scrollbar-y') &&
tableEl.classList.remove('hide-scrollbar-y');
} else {
!tableEl.classList.contains('hide-scrollbar-y') && tableEl.classList.add('hide-scrollbar-y');
}

if (hasScrollBarX) {
tableEl.classList.contains('hide-scrollbar-x') &&
tableEl.classList.remove('hide-scrollbar-x');
} else {
!tableEl.classList.contains('hide-scrollbar-x') && tableEl.classList.add('hide-scrollbar-x');
}

bodyEl!.style.height = 'unset';

if (!unref(getCanResize) || tableData.length === 0) return;
Expand Down
48 changes: 46 additions & 2 deletions src/design/ant/table.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// fix table unnecessary scrollbar
.@{prefix-cls} {
.ant-table-wrapper {
.hide-scrollbar-y {
.ant-spin-nested-loading {
.ant-spin-container {
.ant-table {
Expand All @@ -13,7 +13,7 @@
}

.ant-table-body {
overflow: auto !important;
overflow-y: auto !important;
}
}

Expand All @@ -24,6 +24,50 @@
}
}
}

.ant-table-fixed-left {
.ant-table-body-outer {
.ant-table-body-inner {
overflow-y: auto !important;
}
}
}
}
}
}
}
}

.hide-scrollbar-x {
.ant-spin-nested-loading {
.ant-spin-container {
.ant-table {
.ant-table-content {
.ant-table-scroll {
.ant-table-hide-scrollbar {
//overflow-x: auto !important;
}

.ant-table-body {
overflow: auto !important;
}
}

.ant-table-fixed-right {
.ant-table-body-outer {
.ant-table-body-inner {
overflow-x: auto !important;
}
}
}

.ant-table-fixed-left {
.ant-table-body-outer {
.ant-table-body-inner {
overflow-x: auto !important;
}
}
}
}
}
}
Expand Down

0 comments on commit d8c3820

Please sign in to comment.