-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(list): add Spin overlay for loading and use Empty.PRESENTED_IMAGE_SIMPLE #9511
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |||||||||||||||||||||||||||||||||||
| * 内部 List 容器与 List.Item / List.Item.Meta 实现,用于替代 antd List(antd List 已停止维护) | ||||||||||||||||||||||||||||||||||||
| * 保持与 antd List 相同的 DOM 结构及类名,以便复用 antd 的 list 样式 | ||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||
| import { ConfigProvider, Empty, Grid, Pagination } from 'antd'; | ||||||||||||||||||||||||||||||||||||
| import { ConfigProvider, Empty, Grid, Pagination, Spin } from 'antd'; | ||||||||||||||||||||||||||||||||||||
| import type { PaginationConfig } from 'antd/lib/pagination'; | ||||||||||||||||||||||||||||||||||||
| import { clsx } from 'clsx'; | ||||||||||||||||||||||||||||||||||||
| import React, { useContext, useMemo } from 'react'; | ||||||||||||||||||||||||||||||||||||
|
|
@@ -445,7 +445,7 @@ const ProListContainerInner = React.forwardRef<HTMLDivElement, ListProps<any>>( | |||||||||||||||||||||||||||||||||||
| } else if (!children && !isLoading) { | ||||||||||||||||||||||||||||||||||||
| const emptyContent = locale?.emptyText ?? | ||||||||||||||||||||||||||||||||||||
| (typeof renderEmpty === 'function' ? renderEmpty('List') : null) ?? ( | ||||||||||||||||||||||||||||||||||||
| <Empty description="暂无数据" /> | ||||||||||||||||||||||||||||||||||||
| <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} /> | ||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||
| childrenContent = ( | ||||||||||||||||||||||||||||||||||||
| <div className={`${prefixCls}-empty-text`}>{emptyContent}</div> | ||||||||||||||||||||||||||||||||||||
|
|
@@ -508,13 +508,15 @@ const ProListContainerInner = React.forwardRef<HTMLDivElement, ListProps<any>>( | |||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||
| <ProListContext.Provider value={contextValue}> | ||||||||||||||||||||||||||||||||||||
| <div ref={ref} style={style} className={classString} {...rest}> | ||||||||||||||||||||||||||||||||||||
| {showPaginationTop && paginationNode} | ||||||||||||||||||||||||||||||||||||
| {header && <div className={`${prefixCls}-header`}>{header}</div>} | ||||||||||||||||||||||||||||||||||||
| {childrenContent} | ||||||||||||||||||||||||||||||||||||
| {children} | ||||||||||||||||||||||||||||||||||||
| {footer && <div className={`${prefixCls}-footer`}>{footer}</div>} | ||||||||||||||||||||||||||||||||||||
| {loadMore} | ||||||||||||||||||||||||||||||||||||
| {showPaginationBottom && paginationNode} | ||||||||||||||||||||||||||||||||||||
| <Spin spinning={isLoading}> | ||||||||||||||||||||||||||||||||||||
| {showPaginationTop && paginationNode} | ||||||||||||||||||||||||||||||||||||
| {header && <div className={`${prefixCls}-header`}>{header}</div>} | ||||||||||||||||||||||||||||||||||||
| {childrenContent} | ||||||||||||||||||||||||||||||||||||
| {children} | ||||||||||||||||||||||||||||||||||||
| {footer && <div className={`${prefixCls}-footer`}>{footer}</div>} | ||||||||||||||||||||||||||||||||||||
| {loadMore} | ||||||||||||||||||||||||||||||||||||
| {showPaginationBottom && paginationNode} | ||||||||||||||||||||||||||||||||||||
| </Spin> | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+511
to
+519
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. 🧩 Analysis chain🏁 Script executed: cat -n src/list/ProListBase.tsx | sed -n '450,520p'Repository: ant-design/pro-components Length of output: 2909 🏁 Script executed: cat -n src/list/ProListBase.tsx | sed -n '430,460p'Repository: ant-design/pro-components Length of output: 1286 🏁 Script executed: cat -n src/list/ProListBase.tsx | sed -n '505,525p' && echo "---" && rg -n "children" src/list/ProListBase.tsx | grep -E "(line 515|{children})" | head -20Repository: ant-design/pro-components Length of output: 991 🏁 Script executed: cat -n src/list/ProListBase.tsx | sed -n '155,175p'Repository: ant-design/pro-components Length of output: 782 🏁 Script executed: # Check for any comments around line 515 or in the broader render section
cat -n src/list/ProListBase.tsx | sed -n '500,525p' | grep -i "comment\|todo\|fixme\|hack\|bug" || echo "No comments found in render section"
# Also check the git history of this line to see if there's context
git log --oneline -p src/list/ProListBase.tsx 2>/dev/null | grep -A10 -B10 "children}" | head -50 || echo "Git history not available"Repository: ant-design/pro-components Length of output: 1534 在特定条件下 当 🐛 建议移除重复的 children 渲染 <Spin spinning={isLoading}>
{showPaginationTop && paginationNode}
{header && <div className={`${prefixCls}-header`}>{header}</div>}
{childrenContent}
- {children}
{footer && <div className={`${prefixCls}-footer`}>{footer}</div>}
{loadMore}
{showPaginationBottom && paginationNode}
</Spin>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||
| </ProListContext.Provider> | ||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
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.
This change to use
<Spin>for loading is a good one. However, it interacts with some existing logic in ways that might be unintended. There are two issues to consider:Loading overlay behavior: The spinner won't function as a true overlay on stale data. This is because when
isLoadingis true, the list's content (childrenContent) is replaced by a placeholderdiv(see lines 453-454). This causes the list to appear empty during loading, rather than showing the spinner over the old content. For a better user experience, you might want to remove that logic so the spinner overlays the stale data.Duplicate rendering of children: There's a pre-existing bug where
childrencan be rendered twice. This happens whendataSourceis empty butchildrenare provided. The logic at line 456 setschildrenContent = children, and then both are rendered within the<Spin>component, causing duplication. This should be addressed by refactoring thechildrenContentlogic.Both issues are related to how
childrenContentis determined outside of this changed block. I'd recommend addressing them for this feature to work correctly and to fix the underlying bug.