@@ -12,6 +12,9 @@ interface Props {
12
12
updateStatusBar : ( ( ) => void ) | undefined ; // Only the focused session can update the status bar.
13
13
}
14
14
15
+ // The height to snap to bottom when scroll. TODO: Make this the actual height
16
+ const FOOTER_HEIGHT = 50 ;
17
+
15
18
export class SessionComponent extends React . Component < Props , { } > {
16
19
RENDER_JOBS_COUNT = 25 ;
17
20
@@ -26,7 +29,19 @@ export class SessionComponent extends React.Component<Props, {}> {
26
29
27
30
componentDidMount ( ) {
28
31
this . props . session
29
- . on ( "job" , ( ) => this . props . updateStatusBar && this . props . updateStatusBar ( ) )
32
+ . on ( "job" , ( ) => {
33
+ const s = ( this . refs as any ) . session ;
34
+ if ( s ) {
35
+ if ( s . scrollHeight - s . offsetHeight - s . scrollTop > FOOTER_HEIGHT ) {
36
+ // If we are already close to the bottom,
37
+ // scroll all the way to the bottom
38
+ s . scrollTop = s . scrollHeight ;
39
+ }
40
+ }
41
+ if ( this . props . updateStatusBar ) {
42
+ this . props . updateStatusBar ( ) ;
43
+ }
44
+ } )
30
45
. on ( "vcs-data" , ( ) => this . props . updateStatusBar && this . props . updateStatusBar ( ) ) ;
31
46
}
32
47
@@ -46,8 +61,9 @@ export class SessionComponent extends React.Component<Props, {}> {
46
61
47
62
return (
48
63
< div className = "session"
49
- style = { css . session ( this . props . isFocused ) }
50
- onClick = { this . handleClick . bind ( this ) } >
64
+ ref = "session"
65
+ style = { css . session ( this . props . isFocused ) }
66
+ onClick = { this . handleClick . bind ( this ) } >
51
67
52
68
< div className = "jobs" style = { css . jobs ( this . props . isFocused ) } > { jobs } </ div >
53
69
< div className = "shutter" style = { css . sessionShutter ( this . props . isFocused ) } > </ div >
0 commit comments