From 4020f658a815d9d0ba067d62fbd9da977db9d281 Mon Sep 17 00:00:00 2001 From: Wanpan Date: Sun, 28 Apr 2024 13:44:01 +0800 Subject: [PATCH] docs: tree-select supports onPopupScroll (#48636) * docs: tree-select supports onPopupScroll props * docs: update demo * docs: update version * test: update snapshots * fix: update demo --------- Co-authored-by: lijianan <574980606@qq.com> --- .../__snapshots__/demo-extend.test.ts.snap | 124 +++++++++++++++++- components/tree-select/demo/basic.tsx | 26 +++- components/tree-select/index.en-US.md | 1 + components/tree-select/index.zh-CN.md | 1 + package.json | 2 +- 5 files changed, 149 insertions(+), 5 deletions(-) diff --git a/components/tree-select/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/tree-select/__tests__/__snapshots__/demo-extend.test.ts.snap index f4faf82bf4..ed9fccb6b0 100644 --- a/components/tree-select/__tests__/__snapshots__/demo-extend.test.ts.snap +++ b/components/tree-select/__tests__/__snapshots__/demo-extend.test.ts.snap @@ -423,7 +423,7 @@ exports[`renders components/tree-select/demo/basic.tsx extend context correctly
+
+
+
+
+
+
+
+
- leaf3 + leaf11 diff --git a/components/tree-select/demo/basic.tsx b/components/tree-select/demo/basic.tsx index 009d49f7fb..0cd1c35998 100644 --- a/components/tree-select/demo/basic.tsx +++ b/components/tree-select/demo/basic.tsx @@ -1,3 +1,4 @@ +import type { SyntheticEvent } from 'react'; import React, { useState } from 'react'; import { TreeSelect } from 'antd'; @@ -18,6 +19,22 @@ const treeData = [ value: 'leaf2', title: 'leaf2', }, + { + value: 'leaf3', + title: 'leaf3', + }, + { + value: 'leaf4', + title: 'leaf4', + }, + { + value: 'leaf5', + title: 'leaf5', + }, + { + value: 'leaf6', + title: 'leaf6', + }, ], }, { @@ -25,8 +42,8 @@ const treeData = [ title: 'parent 1-1', children: [ { - value: 'leaf3', - title: leaf3, + value: 'leaf11', + title: leaf11, }, ], }, @@ -40,6 +57,10 @@ const App: React.FC = () => { setValue(newValue); }; + const onPopupScroll = (e: SyntheticEvent) => { + console.log('onPopupScroll', e); + }; + return ( { treeDefaultExpandAll onChange={onChange} treeData={treeData} + onPopupScroll={onPopupScroll} /> ); }; diff --git a/components/tree-select/index.en-US.md b/components/tree-select/index.en-US.md index a8d0804d54..e0d7bef5ba 100644 --- a/components/tree-select/index.en-US.md +++ b/components/tree-select/index.en-US.md @@ -86,6 +86,7 @@ Common props ref:[Common props](/docs/react/common-props) | onSearch | A callback function, can be executed when the search input changes | function(value: string) | - | | | onSelect | A callback function, can be executed when you select a treeNode | function(value, node, extra) | - | | | onTreeExpand | A callback function, can be executed when treeNode expanded | function(expandedKeys) | - | | +| onPopupScroll | Called when dropdown scrolls | (event: MouseEvent) => void | - | 5.17.0 | ### Tree Methods diff --git a/components/tree-select/index.zh-CN.md b/components/tree-select/index.zh-CN.md index c33960329e..f7cd874ada 100644 --- a/components/tree-select/index.zh-CN.md +++ b/components/tree-select/index.zh-CN.md @@ -87,6 +87,7 @@ demo: | onSearch | 文本框值变化时的回调 | function(value: string) | - | | | onSelect | 被选中时调用 | function(value, node, extra) | - | | | onTreeExpand | 展示节点时调用 | function(expandedKeys) | - | | +| onPopupScroll | 下拉列表滚动时的回调 | (event: MouseEvent) => void | - | 5.17.0 | ### Tree 方法 diff --git a/package.json b/package.json index 834b74cc0c..2dd03ed436 100644 --- a/package.json +++ b/package.json @@ -159,7 +159,7 @@ "rc-textarea": "~1.6.3", "rc-tooltip": "~6.2.0", "rc-tree": "~5.8.5", - "rc-tree-select": "~5.19.0", + "rc-tree-select": "~5.20.0", "rc-upload": "~4.5.2", "rc-util": "^5.39.1", "scroll-into-view-if-needed": "^3.1.0",