From: unarist Date: Wed, 11 Oct 2017 09:25:15 +0000 (+0900) Subject: Fix an error when ancestors get loaded before the status itself (#5312) X-Git-Url: https://git.xn--scling-oua.cat.family/?a=commitdiff_plain;h=b0407ece42dd3057716b58a0db930e79d992b0eb;p=mastodon.git Fix an error when ancestors get loaded before the status itself (#5312) When ancestors get loaded, we scroll to the target status (i.e. skip ancestors). However, ancestors may get loaded before the status itself, then it causes TypeError because `this.node` is undefined yet. Since we don't show anything until the status gets loaded, we don't need to scroll to the target status in this time. If we get the status itslef later, it causes `componentDidUpdate` and scrolling correctly. --- diff --git a/app/javascript/mastodon/features/status/index.js b/app/javascript/mastodon/features/status/index.js index abcfee99e..eed8ea260 100644 --- a/app/javascript/mastodon/features/status/index.js +++ b/app/javascript/mastodon/features/status/index.js @@ -240,9 +240,9 @@ export default class Status extends ImmutablePureComponent { } componentDidUpdate () { - const { ancestorsIds } = this.props; + const { status, ancestorsIds } = this.props; - if (ancestorsIds && ancestorsIds.size > 0) { + if (status && ancestorsIds && ancestorsIds.size > 0) { const element = this.node.querySelectorAll('.focusable')[ancestorsIds.size]; element.scrollIntoView(); }