File tree Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -94,18 +94,17 @@ export default class HunkView extends React.Component {
94
94
this . lineElements . set ( line , element ) ;
95
95
}
96
96
97
- componentDidUpdate ( ) {
98
- const selectedLine = Array . from ( this . props . selectedLines ) [ 0 ] ;
99
- if ( selectedLine && this . lineElements . get ( selectedLine ) ) {
100
- // QUESTION: why is this setTimeout needed?
101
- const element = this . lineElements . get ( selectedLine ) ;
102
- setTimeout ( ( ) => {
103
- element . scrollIntoViewIfNeeded ( ) ;
104
- } , 0 ) ;
105
- } else if ( this . props . headHunk === this . props . hunk ) {
106
- this . element . scrollIntoViewIfNeeded ( ) ;
107
- } else if ( this . props . headLine && this . lineElements . has ( this . props . headLine ) ) {
108
- this . lineElements . get ( this . props . headLine ) . scrollIntoViewIfNeeded ( ) ;
97
+ componentDidUpdate ( prevProps ) {
98
+ if ( prevProps . headLine !== this . props . headLine ) {
99
+ if ( this . props . headLine && this . lineElements . has ( this . props . headLine ) ) {
100
+ this . lineElements . get ( this . props . headLine ) . scrollIntoViewIfNeeded ( ) ;
101
+ }
102
+ }
103
+
104
+ if ( prevProps . headHunk !== this . props . headHunk ) {
105
+ if ( this . props . headHunk === this . props . hunk ) {
106
+ this . element . scrollIntoViewIfNeeded ( ) ;
107
+ }
109
108
}
110
109
}
111
110
}
You can’t perform that action at this time.
0 commit comments