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

Fixed crash when the scrollTarget is undefined in ScrollCaptor #3419

Conversation

iulianraduat
Copy link
Contributor

@iulianraduat iulianraduat commented Feb 8, 2019

Fix the following crash in react-select 2.3.0:

Uncaught TypeError: Cannot read property 'scrollHeight' of undefined
at ScrollCaptor.startListening (react-select.esm.js:1353)
at ScrollCaptor.componentDidMount (react-select.esm.js:1342)
at commitLifeCycles (react-dom.development.js:14685)
at commitAllLifeCycles (react-dom.development.js:15905)
at HTMLUnknownElement.callCallback (react-dom.development.js:145)
at Object.invokeGuardedCallbackDev (react-dom.development.js:195)
at invokeGuardedCallback (react-dom.development.js:248)
at commitRoot (react-dom.development.js:16075)
at completeRoot (react-dom.development.js:17463)
at performWorkOnRoot (react-dom.development.js:17391)
at performWork (react-dom.development.js:17295)
at performSyncWork (react-dom.development.js:17267)
at interactiveUpdates$1 (react-dom.development.js:17558)
at interactiveUpdates (react-dom.development.js:2208)
at dispatchInteractiveEvent (react-dom.development.js:4913)`

The crash produced because of the following code:

<NodeResolver innerRef={this.getScrollTarget}>
{this.props.children}
</NodeResolver>

in class ScrollCaptor which is expected to set this.scrollTarget before componentDidMount from ScrollCaptor is called. But NodeResolver calls this.props.innerRef function also in componentDidMount so there is sometimes a time race condition triggered. And it let this.getScrollTarget undefined when componentDidMount from ScrollCaptor executes this.startListening(this.scrollTarget)

The workaround to this crash is to set the props captureMenuScroll={false} of Select as the default value is true because of
captureMenuScroll boolean = !isTouchCapable()

@gwyneplaine
Copy link
Collaborator

thanks for this @iulian-radu-at, merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants