Skip to content

Commit

Permalink
feat: support itemScrollOffset property (#443)
Browse files Browse the repository at this point in the history
* feat: support itemScrollOffset property

* chore: update snapshot

---------

Co-authored-by: dujiaqi <[email protected]>
  • Loading branch information
Yuiai01 and dujiaqi authored Oct 17, 2023
1 parent 2d99469 commit 4119601
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 2 additions & 0 deletions src/OptionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const OptionList: React.RefForwardingComponent<ReviseRefOptionListProps> = (_, r
virtual,
listHeight,
listItemHeight,
listItemScrollOffset,
treeData,
fieldNames,
onSelect,
Expand Down Expand Up @@ -224,6 +225,7 @@ const OptionList: React.RefForwardingComponent<ReviseRefOptionListProps> = (_, r
treeData={memoTreeData as TreeDataNode[]}
height={listHeight}
itemHeight={listItemHeight}
itemScrollOffset={listItemScrollOffset}
virtual={virtual !== false && dropdownMatchSelectWidth !== false}
multiple={multiple}
icon={treeIcon}
Expand Down
5 changes: 5 additions & 0 deletions src/TreeSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export interface TreeSelectProps<
virtual?: boolean;
listHeight?: number;
listItemHeight?: number;
listItemScrollOffset?: number;
onDropdownVisibleChange?: (open: boolean) => void;

// >>> Tree
Expand Down Expand Up @@ -225,6 +226,8 @@ const TreeSelect = React.forwardRef<BaseSelectRef, TreeSelectProps>((props, ref)
virtual,
listHeight = 200,
listItemHeight = 20,
listItemScrollOffset = 0,

onDropdownVisibleChange,
dropdownMatchSelectWidth = true,

Expand Down Expand Up @@ -663,6 +666,7 @@ const TreeSelect = React.forwardRef<BaseSelectRef, TreeSelectProps>((props, ref)
dropdownMatchSelectWidth,
listHeight,
listItemHeight,
listItemScrollOffset,
treeData: filteredTreeData,
fieldNames: mergedFieldNames,
onSelect: onOptionSelect,
Expand All @@ -673,6 +677,7 @@ const TreeSelect = React.forwardRef<BaseSelectRef, TreeSelectProps>((props, ref)
dropdownMatchSelectWidth,
listHeight,
listItemHeight,
listItemScrollOffset,
filteredTreeData,
mergedFieldNames,
onOptionSelect,
Expand Down
1 change: 1 addition & 0 deletions src/TreeSelectContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface TreeSelectContextProps {
dropdownMatchSelectWidth?: boolean | number;
listHeight: number;
listItemHeight: number;
listItemScrollOffset?: number;
treeData: DefaultOptionType[];
fieldNames: InternalFieldName;
onSelect: OnInternalSelect;
Expand Down
4 changes: 0 additions & 4 deletions tests/__snapshots__/Select.checkable.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion tests/__snapshots__/Select.multiple.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 0 additions & 10 deletions tests/__snapshots__/Select.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 4119601

Please sign in to comment.