Skip to content

Commit 4119601

Browse files
Yuiai01dujiaqi
andauthored
feat: support itemScrollOffset property (#443)
* feat: support itemScrollOffset property * chore: update snapshot --------- Co-authored-by: dujiaqi <[email protected]>
1 parent 2d99469 commit 4119601

File tree

7 files changed

+9
-16
lines changed

7 files changed

+9
-16
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"@babel/runtime": "^7.10.1",
7474
"classnames": "2.x",
7575
"rc-select": "~14.9.0",
76-
"rc-tree": "~5.7.0",
76+
"rc-tree": "~5.8.0",
7777
"rc-util": "^5.16.1"
7878
}
7979
}

src/OptionList.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const OptionList: React.RefForwardingComponent<ReviseRefOptionListProps> = (_, r
3737
virtual,
3838
listHeight,
3939
listItemHeight,
40+
listItemScrollOffset,
4041
treeData,
4142
fieldNames,
4243
onSelect,
@@ -224,6 +225,7 @@ const OptionList: React.RefForwardingComponent<ReviseRefOptionListProps> = (_, r
224225
treeData={memoTreeData as TreeDataNode[]}
225226
height={listHeight}
226227
itemHeight={listItemHeight}
228+
itemScrollOffset={listItemScrollOffset}
227229
virtual={virtual !== false && dropdownMatchSelectWidth !== false}
228230
multiple={multiple}
229231
icon={treeIcon}

src/TreeSelect.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ export interface TreeSelectProps<
159159
virtual?: boolean;
160160
listHeight?: number;
161161
listItemHeight?: number;
162+
listItemScrollOffset?: number;
162163
onDropdownVisibleChange?: (open: boolean) => void;
163164

164165
// >>> Tree
@@ -225,6 +226,8 @@ const TreeSelect = React.forwardRef<BaseSelectRef, TreeSelectProps>((props, ref)
225226
virtual,
226227
listHeight = 200,
227228
listItemHeight = 20,
229+
listItemScrollOffset = 0,
230+
228231
onDropdownVisibleChange,
229232
dropdownMatchSelectWidth = true,
230233

@@ -663,6 +666,7 @@ const TreeSelect = React.forwardRef<BaseSelectRef, TreeSelectProps>((props, ref)
663666
dropdownMatchSelectWidth,
664667
listHeight,
665668
listItemHeight,
669+
listItemScrollOffset,
666670
treeData: filteredTreeData,
667671
fieldNames: mergedFieldNames,
668672
onSelect: onOptionSelect,
@@ -673,6 +677,7 @@ const TreeSelect = React.forwardRef<BaseSelectRef, TreeSelectProps>((props, ref)
673677
dropdownMatchSelectWidth,
674678
listHeight,
675679
listItemHeight,
680+
listItemScrollOffset,
676681
filteredTreeData,
677682
mergedFieldNames,
678683
onOptionSelect,

src/TreeSelectContext.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface TreeSelectContextProps {
77
dropdownMatchSelectWidth?: boolean | number;
88
listHeight: number;
99
listItemHeight: number;
10+
listItemScrollOffset?: number;
1011
treeData: DefaultOptionType[];
1112
fieldNames: InternalFieldName;
1213
onSelect: OnInternalSelect;

tests/__snapshots__/Select.checkable.spec.tsx.snap

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ exports[`TreeSelect.checkable uncheck remove by selector not treeCheckStrictly 1
105105
aria-controls="rc_select_TEST_OR_SSR_list"
106106
aria-expanded="true"
107107
aria-haspopup="listbox"
108-
aria-label="Search"
109108
aria-owns="rc_select_TEST_OR_SSR_list"
110109
autocomplete="off"
111110
class="rc-tree-select-selection-search-input"
@@ -298,7 +297,6 @@ exports[`TreeSelect.checkable uncheck remove by selector not treeCheckStrictly 2
298297
aria-controls="rc_select_TEST_OR_SSR_list"
299298
aria-expanded="true"
300299
aria-haspopup="listbox"
301-
aria-label="Search"
302300
aria-owns="rc_select_TEST_OR_SSR_list"
303301
autocomplete="off"
304302
class="rc-tree-select-selection-search-input"
@@ -575,7 +573,6 @@ exports[`TreeSelect.checkable uncheck remove by tree check 1`] = `
575573
aria-controls="rc_select_TEST_OR_SSR_list"
576574
aria-expanded="true"
577575
aria-haspopup="listbox"
578-
aria-label="Search"
579576
aria-owns="rc_select_TEST_OR_SSR_list"
580577
autocomplete="off"
581578
class="rc-tree-select-selection-search-input"
@@ -768,7 +765,6 @@ exports[`TreeSelect.checkable uncheck remove by tree check 2`] = `
768765
aria-controls="rc_select_TEST_OR_SSR_list"
769766
aria-expanded="true"
770767
aria-haspopup="listbox"
771-
aria-label="Search"
772768
aria-owns="rc_select_TEST_OR_SSR_list"
773769
autocomplete="off"
774770
class="rc-tree-select-selection-search-input"

tests/__snapshots__/Select.multiple.spec.js.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ exports[`TreeSelect.multiple can hide search box by showSearch = false 1`] = `
2323
aria-controls="rc_select_TEST_OR_SSR_list"
2424
aria-expanded="false"
2525
aria-haspopup="listbox"
26-
aria-label="Search"
2726
aria-owns="rc_select_TEST_OR_SSR_list"
2827
autocomplete="off"
2928
class="rc-tree-select-selection-search-input"

tests/__snapshots__/Select.spec.tsx.snap

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ exports[`TreeSelect.basic render renders TreeNode correctly 1`] = `
1515
aria-controls="rc_select_TEST_OR_SSR_list"
1616
aria-expanded="true"
1717
aria-haspopup="listbox"
18-
aria-label="Search"
1918
aria-owns="rc_select_TEST_OR_SSR_list"
2019
autocomplete="off"
2120
class="rc-tree-select-selection-search-input"
@@ -209,7 +208,6 @@ exports[`TreeSelect.basic render renders TreeNode correctly with falsy child 1`]
209208
aria-controls="rc_select_TEST_OR_SSR_list"
210209
aria-expanded="true"
211210
aria-haspopup="listbox"
212-
aria-label="Search"
213211
aria-owns="rc_select_TEST_OR_SSR_list"
214212
autocomplete="off"
215213
class="rc-tree-select-selection-search-input"
@@ -412,7 +410,6 @@ exports[`TreeSelect.basic render renders correctly 1`] = `
412410
aria-controls="rc_select_TEST_OR_SSR_list"
413411
aria-expanded="false"
414412
aria-haspopup="listbox"
415-
aria-label="Search"
416413
aria-owns="rc_select_TEST_OR_SSR_list"
417414
autocomplete="off"
418415
class="awesome-selection-search-input"
@@ -455,7 +452,6 @@ exports[`TreeSelect.basic render renders disabled correctly 1`] = `
455452
aria-controls="rc_select_TEST_OR_SSR_list"
456453
aria-expanded="false"
457454
aria-haspopup="listbox"
458-
aria-label="Search"
459455
aria-owns="rc_select_TEST_OR_SSR_list"
460456
autocomplete="off"
461457
class="rc-tree-select-selection-search-input"
@@ -499,7 +495,6 @@ exports[`TreeSelect.basic render renders tree correctly 1`] = `
499495
aria-controls="rc_select_TEST_OR_SSR_list"
500496
aria-expanded="false"
501497
aria-haspopup="listbox"
502-
aria-label="Search"
503498
aria-owns="rc_select_TEST_OR_SSR_list"
504499
autocomplete="off"
505500
class="rc-tree-select-selection-search-input"
@@ -543,7 +538,6 @@ exports[`TreeSelect.basic render renders treeDataSimpleMode correctly 1`] = `
543538
aria-controls="rc_select_TEST_OR_SSR_list"
544539
aria-expanded="true"
545540
aria-haspopup="listbox"
546-
aria-label="Search"
547541
aria-owns="rc_select_TEST_OR_SSR_list"
548542
autocomplete="off"
549543
class="rc-tree-select-selection-search-input"
@@ -683,7 +677,6 @@ exports[`TreeSelect.basic search nodes check tree changed by filter 1`] = `
683677
aria-controls="rc_select_TEST_OR_SSR_list"
684678
aria-expanded="true"
685679
aria-haspopup="listbox"
686-
aria-label="Search"
687680
aria-owns="rc_select_TEST_OR_SSR_list"
688681
autocomplete="off"
689682
class="rc-tree-select-selection-search-input"
@@ -791,7 +784,6 @@ exports[`TreeSelect.basic search nodes check tree changed by filter 2`] = `
791784
aria-controls="rc_select_TEST_OR_SSR_list"
792785
aria-expanded="true"
793786
aria-haspopup="listbox"
794-
aria-label="Search"
795787
aria-owns="rc_select_TEST_OR_SSR_list"
796788
autocomplete="off"
797789
class="rc-tree-select-selection-search-input"
@@ -925,7 +917,6 @@ exports[`TreeSelect.basic search nodes filter node but not remove then 1`] = `
925917
aria-controls="rc_select_TEST_OR_SSR_list"
926918
aria-expanded="true"
927919
aria-haspopup="listbox"
928-
aria-label="Search"
929920
aria-owns="rc_select_TEST_OR_SSR_list"
930921
autocomplete="off"
931922
class="rc-tree-select-selection-search-input"
@@ -1058,7 +1049,6 @@ exports[`TreeSelect.basic search nodes renders search input 1`] = `
10581049
aria-controls="rc_select_TEST_OR_SSR_list"
10591050
aria-expanded="true"
10601051
aria-haspopup="listbox"
1061-
aria-label="Search"
10621052
aria-owns="rc_select_TEST_OR_SSR_list"
10631053
autocomplete="off"
10641054
class="rc-tree-select-selection-search-input"

0 commit comments

Comments
 (0)