-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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(data-table): fixed group column box-shadow error and right fixed … #1833
Conversation
…column render order error
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/tusimple/naive-ui/JDvaCXWdFCb5PBDpzRujGE9kwoKN |
修改内容:
|
function deriveActiveLeftFixedChildrenColumns (): void { | ||
leftActiveFixedChildrenColKeysRef.value = [] | ||
let activeLeftFixedColumn = props.columns.find( | ||
(col) => getColKey(col) === leftActiveFixedColKeyRef.value | ||
) | ||
while (activeLeftFixedColumn && 'children' in activeLeftFixedColumn) { | ||
const length: number = activeLeftFixedColumn.children.length | ||
if (length === 0) break | ||
const nextActiveLeftFixedColumn = | ||
activeLeftFixedColumn.children[length - 1] | ||
leftActiveFixedChildrenColKeysRef.value.push( | ||
getColKey(nextActiveLeftFixedColumn) | ||
) | ||
activeLeftFixedColumn = nextActiveLeftFixedColumn | ||
} | ||
} |
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.
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.
确实应该这么做的
const createActiveRightFixedStyle = ( | ||
rightActiveFixedColKey: string | null | ||
): CNode | null => { | ||
if (rightActiveFixedColKey === null) return null | ||
return c( | ||
`[data-n-id="${ | ||
cProps.componentId as string | ||
}"] [data-col-key="${rightActiveFixedColKey}"]::before`, | ||
{ | ||
boxShadow: 'var(--box-shadow-before)' | ||
} | ||
) | ||
} | ||
|
||
return c([ | ||
createActiveLeftFixedStyle(cProps.leftActiveFixedColKey as string), | ||
createActiveRightFixedStyle(cProps.rightActiveFixedColKey as string), | ||
(cProps.leftActiveFixedChildrenColKeys as string[]).map( | ||
(leftActiveFixedColKey) => | ||
createActiveLeftFixedStyle(leftActiveFixedColKey) |
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.
这块 cProps 需要在函数参数那里把类型声明完全,原先写成 Record<string, string> 是因为凑活够用,在这个 case 下应该把 leftActiveFixedColKey、...、componentId 都写好对应的类型,而不是用 as 来判断类型
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.
已改进 cProps 的类型提示
Codecov Report
@@ Coverage Diff @@
## main #1833 +/- ##
==========================================
- Coverage 64.83% 64.74% -0.09%
==========================================
Files 890 890
Lines 17312 17342 +30
Branches 4104 4107 +3
==========================================
+ Hits 11224 11228 +4
- Misses 5312 5338 +26
Partials 776 776
Continue to review full report at Codecov.
|
fixed group column box-shadow error and right fixed column render order error