Skip to content

Commit b9a0bcd

Browse files
authored
chore: Reset scroll when search text changed (#470)
* fix scroll logic * test case
1 parent ca3ce01 commit b9a0bcd

File tree

4 files changed

+72
-149
lines changed

4 files changed

+72
-149
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"rc-animate": "^2.10.0",
4747
"rc-trigger": "^4.0.0",
4848
"rc-util": "^4.20.0",
49-
"rc-virtual-list": "^1.1.0",
49+
"rc-virtual-list": "^1.1.2",
5050
"warning": "^4.0.3"
5151
},
5252
"devDependencies": {

src/OptionList.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export interface OptionListProps<OptionsType extends object[]> {
3939
export interface RefOptionListProps {
4040
onKeyDown: React.KeyboardEventHandler;
4141
onKeyUp: React.KeyboardEventHandler;
42+
scrollTo?: (index: number) => void;
4243
}
4344

4445
/**
@@ -206,6 +207,10 @@ const OptionList: React.RefForwardingComponent<
206207
}
207208
},
208209
onKeyUp: () => {},
210+
211+
scrollTo: index => {
212+
scrollIntoView(index);
213+
},
209214
}));
210215

211216
// ========================== Render ==========================

0 commit comments

Comments
 (0)