Skip to content

Commit a46e024

Browse files
feat(dropdown): 修改 onVisibleChange 参数结构
- 将 key 参数包装为 info 对象 - 同步更新中英文文档
1 parent 3b0344b commit a46e024

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/components/dropdown/dropdown.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export type DropdownProps = {
3434
closeOnMaskClick?: boolean
3535
closeOnClickAway?: boolean
3636
onChange?: (key: string | null) => void
37-
onVisibleChange?: (visible: boolean, key: string | null) => void
37+
onVisibleChange?: (visible: boolean, info: { key: string | null }) => void
3838
arrowIcon?: ReactNode
3939
/**
4040
* @deprecated use `arrowIcon` instead
@@ -74,7 +74,7 @@ const Dropdown = forwardRef<DropdownRef, PropsWithChildren<DropdownProps>>(
7474
if (v === null) {
7575
closingKeyRef.current = value
7676
} else if (value !== null) {
77-
mergedProps.onVisibleChange?.(true, v)
77+
mergedProps.onVisibleChange?.(true, { key: v })
7878
}
7979
},
8080
})
@@ -192,10 +192,10 @@ const Dropdown = forwardRef<DropdownRef, PropsWithChildren<DropdownProps>>(
192192
: undefined
193193
}
194194
afterShow={() => {
195-
mergedProps.onVisibleChange?.(true, value)
195+
mergedProps.onVisibleChange?.(true, { key: value })
196196
}}
197197
afterClose={() => {
198-
mergedProps.onVisibleChange?.(false, closingKeyRef.current)
198+
mergedProps.onVisibleChange?.(false, { key: closingKeyRef.current })
199199
}}
200200
>
201201
<div ref={contentRef}>

src/components/dropdown/index.en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ It is suitable for filtering, sorting and changing the display range or order of
2222
| closeOnMaskClick | Whether to automatically close after clicking on the mask | `boolean` | `true` |
2323
| defaultActiveKey | The default active `Item` key | `string \| null` | `null` |
2424
| onChange | Triggered when `activeKey` changes | `(activeKey: string \| null)=> void` | - |
25-
| onVisibleChange | Triggered when the dropdown panel is shown or hidden | `(visible: boolean, key: string \| null) => void` | - |
25+
| onVisibleChange | Triggered when the dropdown panel is shown or hidden | `(visible: boolean, info: { key: string \| null }) => void` | - |
2626
| getContainer | The parent container of the custom popup | `HTMLElement \| (() => HTMLElement) \| null` | `document.body` |
2727

2828
### Ref

src/components/dropdown/index.zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
| closeOnMaskClick | 是否在点击遮罩后自动隐藏 | `boolean` | `true` |
2323
| defaultActiveKey | 默认激活的 `Item` `key` | `string \| null` | `null` |
2424
| onChange | `activeKey` 变化时触发 | `(activeKey: string \| null)=> void` | - |
25-
| onVisibleChange | 面板显示/隐藏时触发 | `(visible: boolean, key: string \| null) => void` | - |
25+
| onVisibleChange | 面板显示/隐藏时触发 | `(visible: boolean, info: { key: string \| null }) => void` | - |
2626
| getContainer | 自定义弹窗的父容器 | `HTMLElement \| (() => HTMLElement) \| null` | `document.body` |
2727

2828
### Ref

0 commit comments

Comments
 (0)