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(table): 修复数据变化时,吸底滚动条位置没有变化的问题 #1535

Merged
merged 1 commit into from
Sep 20, 2022
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
5 changes: 4 additions & 1 deletion src/table/base-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default defineComponent({
const tableBodyRef = ref<HTMLTableElement>();
const tableFootHeight = ref(0);
const paginationAffixRef = ref();
const horizontalScrollAffixRef = ref();

const {
virtualScrollClasses, tableLayoutClasses, tableBaseClass, tableColFixedClasses,
Expand Down Expand Up @@ -88,7 +89,7 @@ export default defineComponent({
updateThWidthList,
setRecalculateColWidthFuncRef,
addTableResizeObserver,
} = useFixed(props, context, finalColumns, paginationAffixRef);
} = useFixed(props, context, finalColumns, paginationAffixRef, horizontalScrollAffixRef);

// 1. 表头吸顶;2. 表尾吸底;3. 底部滚动条吸底;4. 分页器吸底
const {
Expand Down Expand Up @@ -309,6 +310,7 @@ export default defineComponent({
refreshTable,
onInnerVirtualScroll,
paginationAffixRef,
horizontalScrollAffixRef,
};
},

Expand Down Expand Up @@ -567,6 +569,7 @@ export default defineComponent({
offsetBottom={0}
props={getAffixProps(this.horizontalScrollAffixedBottom)}
style={{ marginTop: `-${this.scrollbarWidth * 2}px` }}
ref="horizontalScrollAffixRef"
>
<div
ref="horizontalScrollbarRef"
Expand Down
2 changes: 2 additions & 0 deletions src/table/hooks/useFixed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export default function useFixed(
context: SetupContext,
finalColumns: ComputedRef<BaseTableCol<TableRowData>[]>,
paginationAffixRef: Ref,
horizontalScrollAffixRef: Ref,
) {
const {
columns,
Expand Down Expand Up @@ -381,6 +382,7 @@ export default function useFixed(
const updateAffixPosition = () => {
// 在表格高度变化的时候 需要手动调整affix的位置 因为affix本身无法监听到这些变化触发重新计算
paginationAffixRef.value.handleScroll();
horizontalScrollAffixRef.value.handleScroll();
};

const updateThWidthList = (trList: HTMLCollection | { [colKey: string]: number }) => {
Expand Down