From 2b29f5b5f12e2daf577c5e24aadbe1de28d4aed8 Mon Sep 17 00:00:00 2001 From: unarist Date: Wed, 11 Oct 2017 18:25:15 +0900 Subject: [PATCH] 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. --- app/javascript/mastodon/features/status/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/javascript/mastodon/features/status/index.js b/app/javascript/mastodon/features/status/index.js index abcfee99e7..eed8ea2602 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(); }