diff --git a/assets/js/cell/index.js b/assets/js/cell/index.js index 84855342b..f96fe3aeb 100644 --- a/assets/js/cell/index.js +++ b/assets/js/cell/index.js @@ -67,6 +67,10 @@ const Cell = { if (isActive(prevProps) && !isActive(this.props)) { this.liveEditor.blur(); } + + if (!prevProps.isFocused && this.props.isFocused) { + this.el.scrollIntoView({ behavior: "smooth", block: "center" }); + } }, }; diff --git a/assets/js/session/index.js b/assets/js/session/index.js index 4b6defa98..bf5f6e627 100644 --- a/assets/js/session/index.js +++ b/assets/js/session/index.js @@ -45,17 +45,7 @@ const Session = { }, updated() { - const prevProps = this.props; this.props = getProps(this); - - // When a new cell gets focus, center it nicely on the page - if ( - this.props.focusedCellId && - this.props.focusedCellId !== prevProps.focusedCellId - ) { - const cell = this.el.querySelector(`#cell-${this.props.focusedCellId}`); - cell.scrollIntoView({ behavior: "smooth", block: "center" }); - } }, };