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; diff --git a/tests/__snapshots__/Select.checkable.spec.tsx.snap b/tests/__snapshots__/Select.checkable.spec.tsx.snap index 17b6bbfd..fb5d0b12 100644 --- a/tests/__snapshots__/Select.checkable.spec.tsx.snap +++ b/tests/__snapshots__/Select.checkable.spec.tsx.snap @@ -105,7 +105,6 @@ exports[`TreeSelect.checkable uncheck remove by selector not treeCheckStrictly 1 aria-controls="rc_select_TEST_OR_SSR_list" aria-expanded="true" aria-haspopup="listbox" - aria-label="Search" aria-owns="rc_select_TEST_OR_SSR_list" autocomplete="off" class="rc-tree-select-selection-search-input" @@ -298,7 +297,6 @@ exports[`TreeSelect.checkable uncheck remove by selector not treeCheckStrictly 2 aria-controls="rc_select_TEST_OR_SSR_list" aria-expanded="true" aria-haspopup="listbox" - aria-label="Search" aria-owns="rc_select_TEST_OR_SSR_list" autocomplete="off" class="rc-tree-select-selection-search-input" @@ -575,7 +573,6 @@ exports[`TreeSelect.checkable uncheck remove by tree check 1`] = ` aria-controls="rc_select_TEST_OR_SSR_list" aria-expanded="true" aria-haspopup="listbox" - aria-label="Search" aria-owns="rc_select_TEST_OR_SSR_list" autocomplete="off" class="rc-tree-select-selection-search-input" @@ -768,7 +765,6 @@ exports[`TreeSelect.checkable uncheck remove by tree check 2`] = ` aria-controls="rc_select_TEST_OR_SSR_list" aria-expanded="true" aria-haspopup="listbox" - aria-label="Search" aria-owns="rc_select_TEST_OR_SSR_list" autocomplete="off" class="rc-tree-select-selection-search-input" diff --git a/tests/__snapshots__/Select.multiple.spec.js.snap b/tests/__snapshots__/Select.multiple.spec.js.snap index 4a25550b..083a80a8 100644 --- a/tests/__snapshots__/Select.multiple.spec.js.snap +++ b/tests/__snapshots__/Select.multiple.spec.js.snap @@ -23,7 +23,6 @@ exports[`TreeSelect.multiple can hide search box by showSearch = false 1`] = ` aria-controls="rc_select_TEST_OR_SSR_list" aria-expanded="false" aria-haspopup="listbox" - aria-label="Search" aria-owns="rc_select_TEST_OR_SSR_list" autocomplete="off" class="rc-tree-select-selection-search-input" diff --git a/tests/__snapshots__/Select.spec.tsx.snap b/tests/__snapshots__/Select.spec.tsx.snap index b706a9e5..1e449191 100644 --- a/tests/__snapshots__/Select.spec.tsx.snap +++ b/tests/__snapshots__/Select.spec.tsx.snap @@ -15,7 +15,6 @@ exports[`TreeSelect.basic render renders TreeNode correctly 1`] = ` aria-controls="rc_select_TEST_OR_SSR_list" aria-expanded="true" aria-haspopup="listbox" - aria-label="Search" aria-owns="rc_select_TEST_OR_SSR_list" autocomplete="off" class="rc-tree-select-selection-search-input" @@ -209,7 +208,6 @@ exports[`TreeSelect.basic render renders TreeNode correctly with falsy child 1`] aria-controls="rc_select_TEST_OR_SSR_list" aria-expanded="true" aria-haspopup="listbox" - aria-label="Search" aria-owns="rc_select_TEST_OR_SSR_list" autocomplete="off" class="rc-tree-select-selection-search-input" @@ -412,7 +410,6 @@ exports[`TreeSelect.basic render renders correctly 1`] = ` aria-controls="rc_select_TEST_OR_SSR_list" aria-expanded="false" aria-haspopup="listbox" - aria-label="Search" aria-owns="rc_select_TEST_OR_SSR_list" autocomplete="off" class="awesome-selection-search-input" @@ -455,7 +452,6 @@ exports[`TreeSelect.basic render renders disabled correctly 1`] = ` aria-controls="rc_select_TEST_OR_SSR_list" aria-expanded="false" aria-haspopup="listbox" - aria-label="Search" aria-owns="rc_select_TEST_OR_SSR_list" autocomplete="off" class="rc-tree-select-selection-search-input" @@ -499,7 +495,6 @@ exports[`TreeSelect.basic render renders tree correctly 1`] = ` aria-controls="rc_select_TEST_OR_SSR_list" aria-expanded="false" aria-haspopup="listbox" - aria-label="Search" aria-owns="rc_select_TEST_OR_SSR_list" autocomplete="off" class="rc-tree-select-selection-search-input" @@ -543,7 +538,6 @@ exports[`TreeSelect.basic render renders treeDataSimpleMode correctly 1`] = ` aria-controls="rc_select_TEST_OR_SSR_list" aria-expanded="true" aria-haspopup="listbox" - aria-label="Search" aria-owns="rc_select_TEST_OR_SSR_list" autocomplete="off" class="rc-tree-select-selection-search-input" @@ -683,7 +677,6 @@ exports[`TreeSelect.basic search nodes check tree changed by filter 1`] = ` aria-controls="rc_select_TEST_OR_SSR_list" aria-expanded="true" aria-haspopup="listbox" - aria-label="Search" aria-owns="rc_select_TEST_OR_SSR_list" autocomplete="off" class="rc-tree-select-selection-search-input" @@ -791,7 +784,6 @@ exports[`TreeSelect.basic search nodes check tree changed by filter 2`] = ` aria-controls="rc_select_TEST_OR_SSR_list" aria-expanded="true" aria-haspopup="listbox" - aria-label="Search" aria-owns="rc_select_TEST_OR_SSR_list" autocomplete="off" class="rc-tree-select-selection-search-input" @@ -925,7 +917,6 @@ exports[`TreeSelect.basic search nodes filter node but not remove then 1`] = ` aria-controls="rc_select_TEST_OR_SSR_list" aria-expanded="true" aria-haspopup="listbox" - aria-label="Search" aria-owns="rc_select_TEST_OR_SSR_list" autocomplete="off" class="rc-tree-select-selection-search-input" @@ -1058,7 +1049,6 @@ exports[`TreeSelect.basic search nodes renders search input 1`] = ` aria-controls="rc_select_TEST_OR_SSR_list" aria-expanded="true" aria-haspopup="listbox" - aria-label="Search" aria-owns="rc_select_TEST_OR_SSR_list" autocomplete="off" class="rc-tree-select-selection-search-input"