Skip to content

Commit

Permalink
FinalMessage doesn't scroll into view
Browse files Browse the repository at this point in the history
  • Loading branch information
brigand committed Sep 6, 2017
1 parent 929752f commit 3109ffa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/atoms/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class Message extends React.Component {

// the time it takes to write the message
length: PropTypes.number.isRequired,

noScroll: PropTypes.bool,
};

constructor(props) {
Expand Down Expand Up @@ -44,8 +46,12 @@ class Message extends React.Component {
this.setState({entering: false});
timeout(EXPAND_DURATION, () => {
this.setState({didEnter: true});
if (this.el.scrollIntoViewIfNeeded) {
this.el.scrollIntoViewIfNeeded();
if (!this.props.noScroll) {
if (this.el.scrollIntoViewIfNeeded) {
this.el.scrollIntoViewIfNeeded();
} else {
this.el.scrollIntoView();
}
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/sites/babelrc/BabelSite.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class BabelSite extends React.Component {
};

return (
<Message key={JSON.stringify(this.state)} remote length={LENGTHS.FINAL}>
<Message noScroll key={JSON.stringify(this.state)} remote length={LENGTHS.FINAL}>
<FinalMessage data={data} />
</Message>
);
Expand Down

0 comments on commit 3109ffa

Please sign in to comment.