summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
authorJonathan <jonfritz@gmail.com>2017-07-27 08:17:47 -0400
committerJoram Wilander <jwawilander@gmail.com>2017-07-27 08:17:47 -0400
commit27ff8bb146635c7ab0b23f6c5fe7c847b298a483 (patch)
tree7687743d8ddf0252fc94a689b39ffb94032f848f /webapp
parentcc3a95fdd942370bee31aac67c9476f4c8032f1d (diff)
downloadchat-27ff8bb146635c7ab0b23f6c5fe7c847b298a483.tar.gz
chat-27ff8bb146635c7ab0b23f6c5fe7c847b298a483.tar.bz2
chat-27ff8bb146635c7ab0b23f6c5fe7c847b298a483.zip
PLT-7128: Added an undefined check around the scrollIntoView() command to avoid trying to scroll to something that has gone out of scope (#6998)
Diffstat (limited to 'webapp')
-rw-r--r--webapp/components/create_comment.jsx7
1 files changed, 5 insertions, 2 deletions
diff --git a/webapp/components/create_comment.jsx b/webapp/components/create_comment.jsx
index 858f4c68c..a7edb6bc4 100644
--- a/webapp/components/create_comment.jsx
+++ b/webapp/components/create_comment.jsx
@@ -397,8 +397,11 @@ export default class CreateComment extends React.Component {
draft.fileInfos = draft.fileInfos.concat(fileInfos);
PostStore.storeCommentDraft(this.props.rootId, draft);
- // Focus on preview if needed
- this.refs.preview.refs.container.scrollIntoView();
+ // Focus on preview if needed/possible - if user has switched teams since starting the file upload,
+ // the preview will be undefined and the switch will fail
+ if (typeof this.refs.preview != 'undefined' && this.refs.preview) {
+ this.refs.preview.refs.container.scrollIntoView();
+ }
const enableAddButton = this.handleEnableAddButton(draft.message, draft.fileInfos);