scrollable pane null ref check to resolve "Failed to execute 'getComputedStyle' on 'Window'" bug#4039
Merged
dzearing merged 8 commits intomicrosoft:masterfrom Feb 21, 2018
Conversation
added 3 commits
February 20, 2018 14:36
…(root) in _resizeContainer
dzearing
reviewed
Feb 21, 2018
| } | ||
| if (borderLeftWidth) { | ||
| stickyContainer.style.left = root.offsetLeft + parseInt(borderLeftWidth, 10) + 'px'; | ||
| if (root && stickyContainer) { |
Member
There was a problem hiding this comment.
This may be hiding the root cause. Why is the function being called when refs are null?
I believe it's because there is a setTimeout calling it after an unmount.
If you replace this:
setTimeout(() => this._resizeContainer(), 500);With:
this._async.setTimeout(...)Then the async helper will auto cancel the timeout on unmount and you won't have a function call doing potentially dangerous things.
Author
There was a problem hiding this comment.
Ah. didnt see this till after I submitted the clearTimeout changes. Will do.
Author
There was a problem hiding this comment.
This._async.setTimeout worked perfect
dzearing
requested changes
Feb 21, 2018
Member
dzearing
left a comment
There was a problem hiding this comment.
Check why _resizeContainer is called in unmounted scenarios. Fix that instead of checking for null.
added 5 commits
February 20, 2018 20:32
dzearing
approved these changes
Feb 21, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…(root) in _resizeContainer
Pull request checklist
$ npm run changeDescription of changes
Fix Scrollable-Pane._resizeContainer null reference when calling getComputedStyle. This change checks this.refs.root and this.refs.stickyContainer for null before using them. See related bug.
Focus areas to test
Make sure Scrollable-Pane still renders and resizes correctly.
NOTE: When root or stickyContainer is null or undefined, this change makes the assumption that its ok to do nothing.