Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 617
fix: fix sticky header column width with empty data#1323
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
1f9b5a4398cc729d62c0c593d8584cbf636434ccd6File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -27,7 +27,6 @@ function useColumnWidth(colWidths: readonly number[], columCount: number) { | ||
| export interface FixedHeaderProps<RecordType> extends HeaderProps<RecordType> { | ||
| className: string; | ||
| noData: boolean; | ||
| maxContentScroll: boolean; | ||
| colWidths: readonly number[]; | ||
| columCount: number; | ||
| direction: Direction; | ||
| @@ -37,6 +36,7 @@ export interface FixedHeaderProps<RecordType> extends HeaderProps<RecordType> { | ||
| stickyClassName?: string; | ||
| onScroll: (info: { currentTarget: HTMLDivElement; scrollLeft?: number }) => void; | ||
| children: (info: HeaderProps<RecordType>) => React.ReactNode; | ||
| colGroup?: React.ReactNode; | ||
| } | ||
| const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((props, ref) => { | ||
| @@ -50,6 +50,7 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro | ||
| columns, | ||
| flattenColumns, | ||
| colWidths, | ||
| colGroup, | ||
| columCount, | ||
| stickyOffsets, | ||
| direction, | ||
| @@ -58,7 +59,6 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro | ||
| stickyBottomOffset, | ||
| stickyClassName, | ||
| onScroll, | ||
| maxContentScroll, | ||
| children, | ||
| ...restProps | ||
| } = props; | ||
| @@ -98,12 +98,6 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro | ||
| }; | ||
| }, []); | ||
| // Check if all flattenColumns has width | ||
| const allFlattenColumnsWithWidth = React.useMemo( | ||
| () => flattenColumns.every(column => column.width), | ||
| [flattenColumns], | ||
| ); | ||
| // Add scrollbar column | ||
| const lastColumn = flattenColumns[flattenColumns.length - 1]; | ||
| const ScrollBarColumn: ColumnType<unknown> & { scrollbar: true } = { | ||
| @@ -156,7 +150,10 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro | ||
| visibility: noData || mergedColumnWidth ? null : 'hidden', | ||
| }} | ||
| > | ||
| {(!noData || !maxContentScroll || allFlattenColumnsWithWidth) && ( | ||
| {/* use original ColGroup if no data, otherwise use calculated column width */} | ||
| {noData ? ( | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 如果只有 noData 会不会不够,虽然没数据列头不换行了,那还有个场景(列的数据比列头少,也会换行吧?) 我目前的解法是,取 title 的元素,在第一行里 height =0 再渲染一次,撑起宽度 | ||
| colGroup | ||
| ) : ( | ||
| <ColGroup | ||
| colWidths={mergedColumnWidth ? [...mergedColumnWidth, combinationScrollBarSize] : []} | ||
| columCount={columCount + 1} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
使用了
max-content,这里不应该再加 width 的,这样会忽略掉问题。