@@ -14,7 +14,6 @@ import {
1414 fontFamilies ,
1515 useDarkMode ,
1616 cx ,
17- rafraf ,
1817} from '@mongodb-js/compass-components' ;
1918import type {
2019 Runtime ,
@@ -434,14 +433,6 @@ const _Shell: ForwardRefRenderFunction<EditorRef | null, ShellProps> = (
434433 editorRef . current = editor ;
435434 } , [ ] ) ;
436435
437- const scrollToBottom = useCallback ( ( ) => {
438- if ( ! shellInputContainerRef . current ) {
439- return ;
440- }
441-
442- shellInputContainerRef . current . scrollIntoView ( ) ;
443- } , [ shellInputContainerRef ] ) ;
444-
445436 const onShellClicked = useCallback (
446437 ( event : React . MouseEvent ) : void => {
447438 // Focus on input when clicking the shell background (not clicking output).
@@ -473,14 +464,6 @@ const _Shell: ForwardRefRenderFunction<EditorRef | null, ShellProps> = (
473464 }
474465 } , [ onInput , updateShellPrompt ] ) ;
475466
476- useEffect ( ( ) => {
477- rafraf ( ( ) => {
478- // Scroll to the bottom every time we render so the input/output will be
479- // in view.
480- scrollToBottom ( ) ;
481- } ) ;
482- } ) ;
483-
484467 const listInnerContainerRef = useRef < HTMLDivElement | null > ( null ) ;
485468 const setInnerContainerRef = useCallback ( ( ref : HTMLDivElement ) => {
486469 listInnerContainerRef . current = ref ;
@@ -494,7 +477,7 @@ const _Shell: ForwardRefRenderFunction<EditorRef | null, ShellProps> = (
494477 return ;
495478 }
496479 const observer = new ResizeObserver ( ( [ list ] ) => {
497- rafraf ( ( ) => {
480+ requestAnimationFrame ( ( ) => {
498481 setVirtualListInnerHeight ( list . contentRect . height ) ;
499482 } ) ;
500483 } ) ;
@@ -508,8 +491,8 @@ const _Shell: ForwardRefRenderFunction<EditorRef | null, ShellProps> = (
508491 if ( ! shellInputContainerRef . current ) {
509492 return ;
510493 }
511- const observer = new ResizeObserver ( ( [ list ] ) => {
512- setInputEditorHeight ( list . contentRect . height ) ;
494+ const observer = new ResizeObserver ( ( [ input ] ) => {
495+ setInputEditorHeight ( input . contentRect . height ) ;
513496 } ) ;
514497 observer . observe ( shellInputContainerRef . current ) ;
515498 return ( ) => {
@@ -540,7 +523,7 @@ const _Shell: ForwardRefRenderFunction<EditorRef | null, ShellProps> = (
540523 // container, we will set it to the height of the container minus
541524 // the height of the input editor.
542525 height : `min(calc(100% - ${ inputEditorHeight } px), ${ Math . max (
543- virtualListInnerHeight ,
526+ ( output ?? [ ] ) . length > 0 ? virtualListInnerHeight : 1 ,
544527 1
545528 ) } px)`,
546529 } }
0 commit comments