From d3b2e7b01734b55b200d2ef4780b0ff7b1d9d9ef Mon Sep 17 00:00:00 2001 From: dujiaqi Date: Tue, 17 Oct 2023 10:15:33 +0800 Subject: [PATCH] feat: support itemScrollOffset property --- package.json | 2 +- src/OptionList.tsx | 2 ++ src/TreeSelect.tsx | 5 +++++ src/TreeSelectContext.ts | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index e83625b4..6e755481 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ "@babel/runtime": "^7.10.1", "classnames": "2.x", "rc-select": "~14.9.0", - "rc-tree": "~5.7.0", + "rc-tree": "~5.8.0", "rc-util": "^5.16.1" } } diff --git a/src/OptionList.tsx b/src/OptionList.tsx index cdd38532..d96ac542 100644 --- a/src/OptionList.tsx +++ b/src/OptionList.tsx @@ -37,6 +37,7 @@ const OptionList: React.RefForwardingComponent = (_, r virtual, listHeight, listItemHeight, + listItemScrollOffset, treeData, fieldNames, onSelect, @@ -224,6 +225,7 @@ const OptionList: React.RefForwardingComponent = (_, r treeData={memoTreeData as TreeDataNode[]} height={listHeight} itemHeight={listItemHeight} + itemScrollOffset={listItemScrollOffset} virtual={virtual !== false && dropdownMatchSelectWidth !== false} multiple={multiple} icon={treeIcon} diff --git a/src/TreeSelect.tsx b/src/TreeSelect.tsx index 4ced9d50..1fb27b85 100644 --- a/src/TreeSelect.tsx +++ b/src/TreeSelect.tsx @@ -159,6 +159,7 @@ export interface TreeSelectProps< virtual?: boolean; listHeight?: number; listItemHeight?: number; + listItemScrollOffset?: number; onDropdownVisibleChange?: (open: boolean) => void; // >>> Tree @@ -225,6 +226,8 @@ const TreeSelect = React.forwardRef((props, ref) virtual, listHeight = 200, listItemHeight = 20, + listItemScrollOffset = 0, + onDropdownVisibleChange, dropdownMatchSelectWidth = true, @@ -663,6 +666,7 @@ const TreeSelect = React.forwardRef((props, ref) dropdownMatchSelectWidth, listHeight, listItemHeight, + listItemScrollOffset, treeData: filteredTreeData, fieldNames: mergedFieldNames, onSelect: onOptionSelect, @@ -673,6 +677,7 @@ const TreeSelect = React.forwardRef((props, ref) dropdownMatchSelectWidth, listHeight, listItemHeight, + listItemScrollOffset, filteredTreeData, mergedFieldNames, onOptionSelect, diff --git a/src/TreeSelectContext.ts b/src/TreeSelectContext.ts index 0cb40e0f..bcdb223a 100644 --- a/src/TreeSelectContext.ts +++ b/src/TreeSelectContext.ts @@ -7,6 +7,7 @@ export interface TreeSelectContextProps { dropdownMatchSelectWidth?: boolean | number; listHeight: number; listItemHeight: number; + listItemScrollOffset?: number; treeData: DefaultOptionType[]; fieldNames: InternalFieldName; onSelect: OnInternalSelect;