Correctly set focus on new Notebook cells after clicking on inline buttons. (#6708)

This commit is contained in:
Cory Rivera
2019-08-13 14:14:18 -07:00
committed by GitHub
parent e9c234a0ae
commit 60bf331f19
2 changed files with 8 additions and 5 deletions

View File

@@ -11,11 +11,11 @@
<loading-spinner [loading]="isLoading"></loading-spinner>
<div class="hoverButtonsContainer" *ngIf="(cells && cells.length > 0) && !isLoading">
<span class="containerBackground"></span>
<button class="hoverButton" (click)="addCell('code', 0)">
<button class="hoverButton" (click)="addCell('code', 0, $event)">
<div class="addCodeIcon"></div>
<span>{{addCodeLabel}}</span>
</button>
<button class="hoverButton" (click)="addCell('markdown', 0)">
<button class="hoverButton" (click)="addCell('markdown', 0, $event)">
<div class="addTextIcon"></div>
<span>{{addTextLabel}}</span>
</button>
@@ -29,11 +29,11 @@
</div>
<div class="hoverButtonsContainer">
<span class="containerBackground"></span>
<button class="hoverButton" (click)="addCell('code', findCellIndex(cell) + 1)">
<button class="hoverButton" (click)="addCell('code', findCellIndex(cell) + 1, $event)">
<div class="addCodeIcon"></div>
<span>{{addCodeLabel}}</span>
</button>
<button class="hoverButton" (click)="addCell('markdown', findCellIndex(cell) + 1)">
<button class="hoverButton" (click)="addCell('markdown', findCellIndex(cell) + 1, $event)">
<div class="addTextIcon"></div>
<span>{{addTextLabel}}</span>
</button>

View File

@@ -200,7 +200,10 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
}
// Add cell based on cell type
public addCell(cellType: CellType, index?: number) {
public addCell(cellType: CellType, index?: number, event?: Event) {
if (event) {
event.stopPropagation();
}
this._model.addCell(cellType, index);
}