@@ -211,12 +211,15 @@ function onKeypressHandler(e: KeyboardEvent) {
211
211
// if there is a scrollable output, it will be scrolled to the given value if provided or the bottom of the element
212
212
function initializeScroll ( scrollableElement : HTMLElement , disposables : DisposableStore , scrollTop ?: number ) {
213
213
if ( scrollableElement . classList . contains ( scrollableClass ) ) {
214
- scrollableElement . classList . toggle ( 'scrollbar-visible' , scrollableElement . scrollHeight > scrollableElement . clientHeight ) ;
214
+ const scrollbarVisible = scrollableElement . scrollHeight > scrollableElement . clientHeight ;
215
+ scrollableElement . classList . toggle ( 'scrollbar-visible' , scrollbarVisible ) ;
215
216
scrollableElement . scrollTop = scrollTop !== undefined ? scrollTop : scrollableElement . scrollHeight ;
216
- scrollableElement . addEventListener ( 'scroll' , onScrollHandler ) ;
217
- disposables . push ( { dispose : ( ) => scrollableElement . removeEventListener ( 'scroll' , onScrollHandler ) } ) ;
218
- scrollableElement . addEventListener ( 'keydown' , onKeypressHandler ) ;
219
- disposables . push ( { dispose : ( ) => scrollableElement . removeEventListener ( 'keydown' , onKeypressHandler ) } ) ;
217
+ if ( scrollbarVisible ) {
218
+ scrollableElement . addEventListener ( 'scroll' , onScrollHandler ) ;
219
+ disposables . push ( { dispose : ( ) => scrollableElement . removeEventListener ( 'scroll' , onScrollHandler ) } ) ;
220
+ scrollableElement . addEventListener ( 'keydown' , onKeypressHandler ) ;
221
+ disposables . push ( { dispose : ( ) => scrollableElement . removeEventListener ( 'keydown' , onKeypressHandler ) } ) ;
222
+ }
220
223
}
221
224
}
222
225
0 commit comments