mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-09-12 07:54:49 +08:00
Fix auto-scrolling to not be interrupted by editor focus
This commit is contained in:
parent
b3ec5099b0
commit
cefd582802
2 changed files with 4 additions and 10 deletions
|
@ -67,6 +67,10 @@ const Cell = {
|
||||||
if (isActive(prevProps) && !isActive(this.props)) {
|
if (isActive(prevProps) && !isActive(this.props)) {
|
||||||
this.liveEditor.blur();
|
this.liveEditor.blur();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!prevProps.isFocused && this.props.isFocused) {
|
||||||
|
this.el.scrollIntoView({ behavior: "smooth", block: "center" });
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -45,17 +45,7 @@ const Session = {
|
||||||
},
|
},
|
||||||
|
|
||||||
updated() {
|
updated() {
|
||||||
const prevProps = this.props;
|
|
||||||
this.props = getProps(this);
|
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" });
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue