refactor: remove rc-virtual-list from DraggableList (#9258)

This commit is contained in:
one 2025-08-18 09:36:15 +08:00 committed by GitHub
parent 0b8c6ee536
commit afae33d588
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 12 additions and 20 deletions

View File

@ -225,7 +225,6 @@
"prettier": "^3.5.3",
"prettier-plugin-sort-json": "^4.1.1",
"proxy-agent": "^6.5.0",
"rc-virtual-list": "^3.18.6",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-hotkeys-hook": "^4.6.1",

View File

@ -29,14 +29,14 @@ vi.mock('@hello-pangea/dnd', () => {
}
})
// mock VirtualList 只做简单渲染
vi.mock('rc-virtual-list', () => ({
// mock antd list 只做简单渲染
vi.mock('antd', () => ({
__esModule: true,
default: ({ data, itemKey, children }: any) => (
List: ({ dataSource, renderItem }: any) => (
<div data-testid="virtual-list">
{data.map((item: any, idx: number) => (
<div key={item[itemKey] || item} data-testid="virtual-list-item">
{children(item, idx)}
{dataSource.map((item: any, idx: number) => (
<div key={item.id || item} data-testid="virtual-list-item">
{renderItem(item, idx)}
</div>
))}
</div>

View File

@ -1,5 +1,3 @@
/// <reference types="@vitest/browser/context" />
import { render, screen } from '@testing-library/react'
import { describe, expect, it, vi } from 'vitest'
@ -47,11 +45,6 @@ vi.mock('@tanstack/react-virtual', () => ({
})
}))
vi.mock('react-virtualized-auto-sizer', () => ({
__esModule: true,
default: ({ children }) => <div data-testid="auto-sizer">{children({ height: 500, width: 300 })}</div>
}))
vi.mock('@renderer/components/Scrollbar', () => ({
__esModule: true,
default: ({ ref, children, ...props }) => (

View File

@ -9,7 +9,7 @@ import {
ResponderProvided
} from '@hello-pangea/dnd'
import { droppableReorder } from '@renderer/utils'
import VirtualList from 'rc-virtual-list'
import { List } from 'antd'
import { FC } from 'react'
interface Props<T> {
@ -50,8 +50,9 @@ const DraggableList: FC<Props<any>> = ({
<Droppable droppableId="droppable" {...droppableProps}>
{(provided) => (
<div {...provided.droppableProps} ref={provided.innerRef} style={style}>
<VirtualList data={list} itemKey="id">
{(item, index) => {
<List
dataSource={list}
renderItem={(item, index) => {
const id = item.id || item
return (
<Draggable key={`draggable_${id}_${index}`} draggableId={id} index={index}>
@ -71,7 +72,7 @@ const DraggableList: FC<Props<any>> = ({
</Draggable>
)
}}
</VirtualList>
/>
{provided.placeholder}
</div>
)}

View File

@ -8603,7 +8603,6 @@ __metadata:
prettier: "npm:^3.5.3"
prettier-plugin-sort-json: "npm:^4.1.1"
proxy-agent: "npm:^6.5.0"
rc-virtual-list: "npm:^3.18.6"
react: "npm:^19.0.0"
react-dom: "npm:^19.0.0"
react-hotkeys-hook: "npm:^4.6.1"
@ -19042,7 +19041,7 @@ __metadata:
languageName: node
linkType: hard
"rc-virtual-list@npm:^3.14.2, rc-virtual-list@npm:^3.18.6, rc-virtual-list@npm:^3.5.1, rc-virtual-list@npm:^3.5.2":
"rc-virtual-list@npm:^3.14.2, rc-virtual-list@npm:^3.5.1, rc-virtual-list@npm:^3.5.2":
version: 3.18.6
resolution: "rc-virtual-list@npm:3.18.6"
dependencies: