Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v2] add listener to ScrollCaptor, even when no scroll is available on mount #2861

Merged
merged 1 commit into from
Sep 12, 2019
Merged
Changes from all 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
5 changes: 1 addition & 4 deletions packages/react-select/src/internal/ScrollCaptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ class ScrollCaptor extends Component<CaptorProps> {
this.stopListening(this.scrollTarget);
}
startListening(el: HTMLElement) {
// bail early if no scroll available
// bail early if no element is available to attach to
if (!el) return;
jossmac marked this conversation as resolved.
Show resolved Hide resolved
if (el.scrollHeight <= el.clientHeight) return;

// all the if statements are to appease Flow 😢
if (typeof el.addEventListener === 'function') {
Expand All @@ -41,8 +40,6 @@ class ScrollCaptor extends Component<CaptorProps> {
}
}
stopListening(el: HTMLElement) {
// bail early if no scroll available
if (el.scrollHeight <= el.clientHeight) return;

// all the if statements are to appease Flow 😢
if (typeof el.removeEventListener === 'function') {
Expand Down