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(comp:table): trigger scroll when column widths changes #1142

Merged
merged 1 commit into from
Sep 15, 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
13 changes: 11 additions & 2 deletions packages/components/table/src/main/MainTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
watch,
} from 'vue'

import { isNumber } from 'lodash-es'
import { debounce, isNumber } from 'lodash-es'

import { offResize, onResize } from '@idux/cdk/resize'
import { CdkVirtualScroll, type VirtualContentRenderFn, type VirtualItemRenderFn } from '@idux/cdk/scroll'
Expand All @@ -45,6 +45,7 @@ export default defineComponent({
mergedPrefixCls,
mergedSize,
mergedAutoHeight,
columnWidths,
changeColumnWidth,
flattedData,
isSticky,
Expand Down Expand Up @@ -80,7 +81,6 @@ export default defineComponent({
const handleWrapperResize = (evt: ResizeObserverEntry) => {
const { offsetWidth } = evt.target as HTMLDivElement
if (offsetWidth !== mainTableWidth.value) {
triggerScroll()
mainTableWidth.value = offsetWidth
}
}
Expand All @@ -94,6 +94,15 @@ export default defineComponent({
}
})

// see https://github.com/IDuxFE/idux/issues/1140
const handlerColumnWidthsChange = () => {
const currScrollLeft = convertElement(scrollBodyRef)?.scrollLeft
if (currScrollLeft === 0) {
triggerScroll()
}
}
watch(columnWidths, debounce(handlerColumnWidthsChange, 16))

onResize(mainTableRef.value, handleWrapperResize)
})

Expand Down
4 changes: 2 additions & 2 deletions packages/components/table/style/fixed.less
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
background-color: transparent !important;
}

&-ellipsis&-fix-start-last,
&-ellipsis&-fix-end-first {
&-cell-ellipsis&-fix-start-last,
&-cell-ellipsis&-fix-end-first {
overflow: visible;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/pro/table/src/ProTableLayoutTool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default defineComponent({
const triggerNode = slots.default ? (
slots.default({ attrs })
) : (
<span {...attrs} class={`${prefixCls}-trigger`} title={locale.table.layout.title}>
<span class={`${prefixCls}-trigger`} {...attrs}>
<IxIcon name="ellipsis" />
</span>
)
Expand Down