Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export default () => (
| dropdownRender | render custom dropdown menu | (menu: React.Node) => ReactNode | - |
| loading | show loading icon in arrow | boolean | false |
| virtual | Disable virtual scroll | boolean | true |
| disableAutoScroll | Disable auto scroll to selected option | boolean | false |
| direction | direction of dropdown | 'ltr' \| 'rtl' | 'ltr' |
| optionRender | Custom rendering options | (oriOption: FlattenOptionData\<BaseOptionType\> , info: { index: number }) => React.ReactNode | - |
| labelRender | Custom rendering label | (props: LabelInValueType) => React.ReactNode | - |
Expand Down
3 changes: 2 additions & 1 deletion src/OptionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const OptionList: React.ForwardRefRenderFunction<RefOptionListProps, {}> = (_, r
flattenOptions,
onActiveValue,
defaultActiveFirstOption,
disableAutoScroll,
onSelect,
menuItemSelectedIcon,
rawValues,
Expand Down Expand Up @@ -157,7 +158,7 @@ const OptionList: React.ForwardRefRenderFunction<RefOptionListProps, {}> = (_, r
*/
let timeoutId: NodeJS.Timeout;

if (!multiple && open && rawValues.size === 1) {
if (!disableAutoScroll && !multiple && open && rawValues.size === 1) {
const value: RawValueType = Array.from(rawValues)[0];
// Scroll to the option closest to the searchValue if searching.
const index = memoFlattenOptions.findIndex(({ data }) =>
Expand Down
4 changes: 4 additions & 0 deletions src/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export interface SelectProps<
info: { index: number },
) => React.ReactNode;
defaultActiveFirstOption?: boolean;
disableAutoScroll?: boolean;
virtual?: boolean;
direction?: 'ltr' | 'rtl';
listHeight?: number;
Expand Down Expand Up @@ -214,6 +215,7 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
optionRender,
children,
defaultActiveFirstOption,
disableAutoScroll,
menuItemSelectedIcon,
virtual,
direction,
Expand Down Expand Up @@ -675,6 +677,7 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
flattenOptions: displayOptions,
onActiveValue,
defaultActiveFirstOption: mergedDefaultActiveFirstOption,
disableAutoScroll,
onSelect: onInternalSelect,
menuItemSelectedIcon,
rawValues,
Expand All @@ -695,6 +698,7 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
displayOptions,
onActiveValue,
mergedDefaultActiveFirstOption,
disableAutoScroll,
onInternalSelect,
menuItemSelectedIcon,
rawValues,
Expand Down
1 change: 1 addition & 0 deletions src/SelectContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface SelectContextProps {
listItemHeight?: number;
childrenAsData?: boolean;
maxCount?: number;
disableAutoScroll?: boolean;
}

const SelectContext = React.createContext<SelectContextProps>(null);
Expand Down