Stop grabbing focus when nb editor isn't in view (#7466)

* Stop grabbing focus when nb editor isn't in view

* Add comments
This commit is contained in:
Chris LaFreniere
2019-10-02 11:56:57 -07:00
committed by GitHub
parent 79e2c56ec8
commit b8976785fd
2 changed files with 6 additions and 2 deletions

View File

@@ -305,7 +305,9 @@ export class CodeComponent extends AngularDisposable implements OnInit, OnChange
}
private setFocusAndScroll(): void {
if (this.cellModel.id === this._activeCellId) {
// If offsetParent is null, the element isn't visible
// In this case, we don't want a cell to grab focus for an editor that isn't in the foreground
if (this.cellModel.id === this._activeCellId && this._editor.getContainer().offsetParent) {
this._editor.focus();
this._editor.getContainer().scrollIntoView({ behavior: 'smooth', block: 'nearest' });
}

View File

@@ -54,7 +54,9 @@ export class OutputAreaComponent extends AngularDisposable implements OnInit {
}
private setFocusAndScroll(node: HTMLElement): void {
if (node) {
// If offsetParent is null, the element isn't visible
// In this case, we don't want a cell to grab focus for an editor that isn't in the foreground
if (node && node.offsetParent) {
node.focus();
node.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
}