about summary refs log tree commit diff
path: root/app/javascript
diff options
context:
space:
mode:
authorunarist <m.unarist@gmail.com>2017-10-11 18:25:15 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-10-11 11:25:15 +0200
commitb0407ece42dd3057716b58a0db930e79d992b0eb (patch)
treeed38feb7dccc8eec7ec43a07073644da95dd1740 /app/javascript
parent9b3d8ee3467e262e50a8e7414d5aadae8e345650 (diff)
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.
Diffstat (limited to 'app/javascript')
-rw-r--r--app/javascript/mastodon/features/status/index.js4
1 files changed, 2 insertions, 2 deletions
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();
     }