Skip to content

Commit

Permalink
Scroll selected option into view when receiving refs
Browse files Browse the repository at this point in the history
  • Loading branch information
JefHellemansBlockbax committed Oct 19, 2023
1 parent 2f94e8d commit 02d80ba
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/react-select/src/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -620,10 +620,16 @@ export default class Select<
focusedOptionRef: HTMLDivElement | null = null;
getFocusedOptionRef: RefCallback<HTMLDivElement> = (ref) => {
this.focusedOptionRef = ref;
if (this.menuListRef && this.focusedOptionRef) {
scrollIntoView(this.menuListRef, this.focusedOptionRef);
}
};
menuListRef: HTMLDivElement | null = null;
getMenuListRef: RefCallback<HTMLDivElement> = (ref) => {
this.menuListRef = ref;
if (this.menuListRef && this.focusedOptionRef) {
scrollIntoView(this.menuListRef, this.focusedOptionRef);
}
};
inputRef: HTMLInputElement | null = null;
getInputRef: RefCallback<HTMLInputElement> = (ref) => {
Expand Down

0 comments on commit 02d80ba

Please sign in to comment.