-
-
Notifications
You must be signed in to change notification settings - Fork 611
fix: solve fixed column's shadow display unexpected issue #1081
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
Merged
+6,671
−40
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5871a11
fix: solve fixed column's shadow display unexpected issue
kiner-tang c368c6f
fix: solve fixed column's shadow display unexpected issue
kiner-tang f9cd6da
fix: solve fixed column's shadow display unexpected issue
kiner-tang 53d664e
fix: solve fixed column's shadow display unexpected issue
kiner-tang 81fedad
Merge branch 'master' into fix-shadow
kiner-tang 17bed24
fix: solve fixed column's shadow display unexpected issue
kiner-tang b34469b
feat: add test case
kiner-tang 8ed1db8
feat: optimize code
kiner-tang 909ae2d
feat: optimize code
kiner-tang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: shadow | ||
nav: | ||
title: Demo | ||
path: /demo | ||
--- | ||
|
||
<code src="../examples/shadow.tsx"></code> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
import React from 'react'; | ||
import Table from 'rc-table'; | ||
import '../../assets/index.less'; | ||
import type { ColumnsType } from '@/interface'; | ||
|
||
interface DataType { | ||
key: React.Key; | ||
name: string; | ||
age: number; | ||
street: string; | ||
building: string; | ||
number: number; | ||
companyAddress: string; | ||
companyName: string; | ||
gender: string; | ||
} | ||
|
||
const columns: TableColumnsType<DataType> = [ | ||
{ | ||
title: 'Other', | ||
fixed: 'left', | ||
ellipsis: true, | ||
children: [ | ||
{ | ||
title: 'Age', | ||
dataIndex: 'age', | ||
key: 'age', | ||
width: 150, | ||
fixed: 'left', | ||
ellipsis: true, | ||
sorter: (a, b) => a.age - b.age, | ||
}, | ||
{ | ||
title: 'Address', | ||
children: [ | ||
{ | ||
title: 'Street', | ||
dataIndex: 'street', | ||
key: 'street', | ||
width: 150, | ||
fixed: 'left', | ||
ellipsis: true, | ||
}, | ||
{ | ||
title: 'Block', | ||
children: [ | ||
{ | ||
title: 'Door No.', | ||
dataIndex: 'number', | ||
key: 'number', | ||
width: 100, | ||
fixed: 'left', | ||
ellipsis: true, | ||
}, | ||
{ | ||
title: 'Building', | ||
dataIndex: 'building', | ||
key: 'building', | ||
width: 100, | ||
fixed: 'left', | ||
ellipsis: true, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
title: 'Name', | ||
dataIndex: 'name', | ||
key: 'name', | ||
width: 100, | ||
filters: [ | ||
{ | ||
text: 'Joe', | ||
value: 'Joe', | ||
}, | ||
{ | ||
text: 'John', | ||
value: 'John', | ||
}, | ||
], | ||
onFilter: (value: string, record) => record.name.indexOf(value) === 0, | ||
}, | ||
{ | ||
title: 'Company', | ||
children: [ | ||
{ | ||
title: 'Company Address', | ||
dataIndex: 'companyAddress', | ||
key: 'companyAddress', | ||
width: 200, | ||
}, | ||
{ | ||
title: 'Company Name', | ||
dataIndex: 'companyName', | ||
key: 'companyName', | ||
}, | ||
], | ||
}, | ||
{ | ||
title: 'Gender', | ||
dataIndex: 'gender', | ||
key: 'gender', | ||
width: 80, | ||
fixed: 'right', | ||
}, | ||
]; | ||
|
||
const data: DataType[] = []; | ||
for (let i = 0; i < 100; i++) { | ||
data.push({ | ||
key: i, | ||
name: 'John Brown', | ||
age: i + 1, | ||
street: 'Lake Park', | ||
building: 'C', | ||
number: 2035, | ||
companyAddress: 'Lake Street 42', | ||
companyName: 'SoftLake Co', | ||
gender: 'M', | ||
}); | ||
} | ||
|
||
interface User { | ||
key: number; | ||
name: string; | ||
} | ||
|
||
const columns2: ColumnsType<User> = [ | ||
{ | ||
title: '父表头右侧的阴影导致整个表格最右侧有空隙', | ||
key: 'title', | ||
children: [ | ||
{ | ||
key: 'name0', | ||
title: 'Name0', | ||
fixed: 'left', | ||
dataIndex: 'name0', | ||
width: 100, | ||
}, | ||
{ | ||
key: 'name1', | ||
title: 'Name1', | ||
fixed: 'left', | ||
dataIndex: 'name1', | ||
width: 100, | ||
}, | ||
{ | ||
key: 'name2', | ||
title: 'Name2', | ||
dataIndex: 'name2', | ||
width: 500, | ||
}, | ||
{ | ||
key: 'name3', | ||
title: 'Name3', | ||
fixed: 'right', | ||
dataIndex: 'name3', | ||
width: 100, | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
const data2: User[] = [ | ||
{ | ||
key: 0, | ||
name: 'Jack', | ||
}, | ||
{ | ||
key: 1, | ||
name: 'Jack1', | ||
}, | ||
{ | ||
key: 2, | ||
name: 'Jack1', | ||
}, | ||
]; | ||
|
||
const Demo = () => ( | ||
<div> | ||
<h2>colSpan & rowSpan</h2> | ||
<Table columns={columns} data={data} className="table" scroll={{ x: 1500, y: 500 }} /> | ||
<hr /> | ||
<Table columns={columns2} data={data2} className="table" scroll={{ x: 1500, y: 500 }} /> | ||
</div> | ||
); | ||
|
||
export default Demo; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
import * as React from 'react'; | ||
import type { ColumnsType, ColumnType, StickyOffsets } from '../interface'; | ||
import type { ColumnType, StickyOffsets } from '../interface'; | ||
|
||
type FlattenColumns<RecordType> = readonly (ColumnType<RecordType> & { scrollbar?: boolean })[]; | ||
|
||
const SummaryContext = React.createContext<{ | ||
stickyOffsets?: StickyOffsets; | ||
scrollColumnIndex?: number; | ||
flattenColumns?: FlattenColumns<any>; | ||
columns?: ColumnsType<any>; | ||
}>({}); | ||
|
||
export default SummaryContext; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,4 @@ | ||
import type { | ||
ColumnGroupType, | ||
ColumnType, | ||
Direction, | ||
FixedType, | ||
StickyOffsets, | ||
} from '../interface'; | ||
import type { Direction, FixedType, StickyOffsets } from '../interface'; | ||
|
||
export interface FixedInfo { | ||
fixLeft: number | false; | ||
|
@@ -19,13 +13,12 @@ export interface FixedInfo { | |
isSticky: boolean; | ||
} | ||
|
||
export function getCellFixedInfo<RecordType = any>( | ||
export function getCellFixedInfo( | ||
colStart: number, | ||
colEnd: number, | ||
columns: readonly { fixed?: FixedType }[], | ||
stickyOffsets: StickyOffsets, | ||
direction: Direction, | ||
curColumns?: ColumnType<RecordType> | ColumnGroupType<RecordType>, | ||
): FixedInfo { | ||
const startColumn = columns[colStart] || {}; | ||
const endColumn = columns[colEnd] || {}; | ||
|
@@ -48,8 +41,11 @@ export function getCellFixedInfo<RecordType = any>( | |
const nextColumn = columns[colEnd + 1]; | ||
const prevColumn = columns[colStart - 1]; | ||
|
||
// no children only | ||
const canLastFix = !(curColumns as ColumnGroupType<RecordType>)?.children; | ||
// need show shadow only when canLastFix is true | ||
const canLastFix = | ||
(nextColumn && nextColumn.fixed === undefined) || | ||
(prevColumn && prevColumn.fixed === undefined) || | ||
columns.every(col => col.fixed === 'left'); | ||
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. fixed 有左有右,这个只看 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. |
||
|
||
if (direction === 'rtl') { | ||
if (fixLeft !== undefined) { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.