Fix auto-scrolling to not be interrupted by editor focus

This commit is contained in:
Jonatan Kłosko 2021-02-01 18:21:12 +01:00
parent b3ec5099b0
commit cefd582802
2 changed files with 4 additions and 10 deletions

View file

@ -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" });
}
},
};

View file

@ -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" });
}
},
};