Skip to content

fix(elevator): v15 适配 & 选中值支持受控 #3210

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
merged 24 commits into from
Jun 7, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions src/packages/elevator/demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,15 @@ const ElevatorDemo = () => {
<>
<div className="demo">
<h2>{translated.basic}</h2>
<div style={{ background: 'white' }}>
<Demo1 />
</div>
<Demo1 />
<h2>{translated.customIndex}</h2>
<div style={{ background: 'white' }}>
<Demo2 />
</div>
<Demo2 />
<h2>{translated.showKeys}</h2>
<div style={{ background: 'white' }}>
<Demo3 />
</div>
<Demo3 />
<h2>{translated.sticky}</h2>
<div style={{ background: 'white' }}>
<Demo4 />
</div>
<Demo4 />
<h2>{translated.customContent}</h2>
<div style={{ background: 'white' }}>
<Demo5 />
</div>
<Demo5 />
</div>
</>
)
Expand Down
60 changes: 53 additions & 7 deletions src/packages/elevator/demos/h5/demo1.tsx
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

list 提示 类型不匹配、

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,20 @@ const Demo1 = () => {
title: 'G',
list: [
{
name: '广西',
id: 3,
name: '甘肃',
id: 31,
},
{
name: '广东',
id: 4,
id: 32,
},
{
name: '广东',
id: 33,
},
{
name: '贵州',
id: 34,
},
],
},
Expand All @@ -39,15 +47,53 @@ const Demo1 = () => {
list: [
{
name: '湖南',
id: 5,
id: 41,
},
{
name: '湖北',
id: 42,
},
{
name: '湖北',
id: 6,
id: 43,
},
{
name: '湖南',
id: 44,
},
{
name: '海南',
id: 45,
},
],
},
{
title: 'L',
list: [
{
name: '辽宁',
id: 51,
},
],
},
{
title: 'S',
list: [
{
name: '山东',
id: 51,
},
{
name: '山西',
id: 52,
},
{
name: '上海',
id: 53,
},
{
name: '河南',
id: 7,
name: '陕西',
id: 54,
},
Comment on lines +51 to 97
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

需注意 ID 重复问题

在数据结构中发现了重复的 ID:山东(ID 51)和辽宁(ID 51)使用了相同的 ID 值。这可能在某些操作中导致意外行为,例如在点击回调中通过 ID 识别具体项目时。

建议修复重复的 ID 问题:

-          id: 51,
+          id: 61,

🏁 Script executed:

#!/bin/bash
# 检查所有 demo 文件中是否存在重复的 ID
grep -r "id: 51" src/packages/elevator/demos/

Length of output: 527


需修复:多处演示文件中存在 ID 重复

根据检查结果,id: 51 在以下文件中出现多次,会导致通过 ID 定位项目时产生歧义,请统一调整为唯一值(可参考 GB/T 2260 省级行政区划代码或按业务需求自定义):

  • src/packages/elevator/demos/h5/demo1.tsx (2 处)
  • src/packages/elevator/demos/h5/demo3.tsx
  • src/packages/elevator/demos/h5/demo5.tsx
  • src/packages/elevator/demos/taro/demo1.tsx (2 处)
  • src/packages/elevator/demos/taro/demo3.tsx
  • src/packages/elevator/demos/taro/demo5.tsx

示例修复(以 h5/demo1.tsx 为例):

--- a/src/packages/elevator/demos/h5/demo1.tsx
@@ -55,7 +55,7 @@
     {
       title: 'L',
       list: [
-        { name: '辽宁', id: 51 },
+        { name: '辽宁', id: 21 }, // 官方省份编码:辽宁 = 21
       ],
     },
     {
@@ -62,7 +62,7 @@
     {
       title: 'S',
       list: [
-        { name: '山东', id: 51 },
+        { name: '山东', id: 37 }, // 官方省份编码:山东 = 37
         { name: '山西', id: 52 },
         { name: '上海', id: 53 },
         { name: '陕西', id: 54 },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
},
{
name: '湖北',
id: 42,
},
{
name: '湖北',
id: 6,
id: 43,
},
{
name: '湖南',
id: 44,
},
{
name: '海南',
id: 45,
},
],
},
{
title: 'L',
list: [
{
name: '辽宁',
id: 51,
},
],
},
{
title: 'S',
list: [
{
name: '山东',
id: 51,
},
{
name: '山西',
id: 52,
},
{
name: '上海',
id: 53,
},
{
name: '河南',
id: 7,
name: '陕西',
id: 54,
},
{
title: 'L',
list: [
{
name: '辽宁',
id: 21, // 官方省份编码:辽宁 = 21
},
],
},
{
title: 'S',
list: [
{
name: '山东',
id: 37, // 官方省份编码:山东 = 37
},
{
name: '山西',
id: 52,
},
{
name: '上海',
id: 53,
},
{
name: '陕西',
id: 54,
},
],
},

],
},
Expand Down
39 changes: 32 additions & 7 deletions src/packages/elevator/demos/h5/demo3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,20 @@ const Demo3 = () => {
title: 'G',
list: [
{
name: '广西',
id: 3,
name: '甘肃',
id: 31,
},
{
name: '广东',
id: 4,
id: 32,
},
{
name: '广东',
id: 33,
},
{
name: '贵州',
id: 34,
},
],
},
Expand All @@ -39,15 +47,32 @@ const Demo3 = () => {
list: [
{
name: '湖南',
id: 5,
id: 41,
},
{
name: '湖北',
id: 6,
id: 42,
},
{
name: '河南',
id: 7,
name: '湖北',
id: 43,
},
{
name: '湖南',
id: 44,
},
{
name: '海南',
id: 45,
},
],
},
{
title: 'L',
list: [
{
name: '辽宁',
id: 51,
},
],
},
Expand Down
1 change: 1 addition & 0 deletions src/packages/elevator/demos/h5/demo4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ const Demo4 = () => {
}
return (
<Elevator
mode="vertical"
list={dataList}
height="220"
sticky
Expand Down
55 changes: 46 additions & 9 deletions src/packages/elevator/demos/h5/demo5.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,20 @@ const Demo5 = () => {
title: 'G',
list: [
{
name: '广西',
id: 3,
name: '甘肃',
id: 31,
},
{
name: '广东',
id: 4,
id: 32,
},
{
name: '广东',
id: 33,
},
{
name: '贵州',
id: 34,
},
],
},
Expand All @@ -40,15 +48,44 @@ const Demo5 = () => {
list: [
{
name: '湖南',
id: 5,
id: 41,
},
{
name: '湖北',
id: 42,
},
{
name: '湖北',
id: 6,
id: 43,
},
{
name: '湖南',
id: 44,
},
{
name: '海南',
id: 45,
},
],
},
{
title: 'S',
list: [
{
name: '山东',
id: 51,
},
{
name: '山西',
id: 52,
},
{
name: '上海',
id: 53,
},
{
name: '河南',
id: 7,
name: '陕西',
id: 54,
},
],
},
Expand All @@ -71,8 +108,8 @@ const Demo5 = () => {
{(value) => {
return (
<>
<Fabulous width={12} height={12} />
<span style={{ marginLeft: '15px' }}>{value?.name}</span>
<span>{value?.name}</span>
<Fabulous style={{ marginLeft: '4px' }} height={12} />
</>
)
}}
Expand Down
60 changes: 53 additions & 7 deletions src/packages/elevator/demos/taro/demo1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,20 @@ const Demo1 = () => {
title: 'G',
list: [
{
name: '广西',
id: 3,
name: '甘肃',
id: 31,
},
{
name: '广东',
id: 4,
id: 32,
},
{
name: '广东',
id: 33,
},
{
name: '贵州',
id: 34,
},
],
},
Expand All @@ -39,15 +47,53 @@ const Demo1 = () => {
list: [
{
name: '湖南',
id: 5,
id: 41,
},
{
name: '湖北',
id: 42,
},
{
name: '湖北',
id: 6,
id: 43,
},
{
name: '湖南',
id: 44,
},
{
name: '海南',
id: 45,
},
],
},
{
title: 'L',
list: [
{
name: '辽宁',
id: 51,
},
],
},
{
title: 'S',
list: [
{
name: '山东',
id: 51,
},
{
name: '山西',
id: 52,
},
{
name: '上海',
id: 53,
},
{
name: '河南',
id: 7,
name: '陕西',
id: 54,
},
Comment on lines +71 to 97
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

新增 'L' 和 'S' 组数据

新增了 'L' 和 'S' 组数据,包含多个省市。这一变更与 H5 演示保持一致,但存在与 H5 demo1 相同的 ID 重复问题。

山东(ID 51)和辽宁(ID 51)使用了相同的 ID,这可能导致在回调函数中难以区分这两个不同的条目。建议修复:

-          id: 51,
+          id: 61,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
title: 'L',
list: [
{
name: '辽宁',
id: 51,
},
],
},
{
title: 'S',
list: [
{
name: '山东',
id: 51,
},
{
name: '山西',
id: 52,
},
{
name: '上海',
id: 53,
},
{
name: '河南',
id: 7,
name: '陕西',
id: 54,
},
title: 'L',
list: [
{
name: '辽宁',
id: 51,
},
],
},
{
title: 'S',
list: [
{
name: '山东',
id: 61,
},
{
name: '山西',
id: 52,
},
{
name: '上海',
id: 53,
},
{
name: '陕西',
id: 54,
},
],
},

],
},
Expand Down
Loading
Loading