Fix active cell update on tabbing (#18614)

* listen on focus_in of toolbar

* update styles on focus_in

* listen for active cell change on notebook componen

* add tabbing order to textcells

* remove duplicate listener

* clean up

* undo

* remove visible check from cellToolbar

* remove duplicate detectChanges on updateActiveCell

* only update active cell if it's already not

* add aria-label for accessibility

* localize the aria label

* refactor

* add cellLabel property to CellModel

* remove updateActiveCell from code component

* regression from merge fix

* set edit mode as true when focusing on cell

* moce check to model

* merge changes correctly

* update edit mode if code cell

* fixes

Co-authored-by: barbaravaldez <bavaldez@microsoft.com>
Co-authored-by: chgagnon <chgagnon@microsoft.com>
This commit is contained in:
Maddy
2022-04-08 12:31:30 -07:00
committed by GitHub
parent 41b639c7d6
commit 4191ef8aa5
9 changed files with 37 additions and 16 deletions

View File

@@ -46,6 +46,7 @@ export interface QueryResultId {
export class CellModel extends Disposable implements ICellModel {
public id: string;
public cellLabel: string;
private _cellType: nb.CellType;
private _source: string | string[];
@@ -120,6 +121,11 @@ export class CellModel extends Disposable implements ICellModel {
}
// if the fromJson() method was already called and _cellGuid was previously set, don't generate another UUID unnecessarily
this._cellGuid = this._cellGuid || generateUuid();
if (this._cellType === 'code') {
this.cellLabel = localize('codeCellLabel', "Code Cell {0}", this.id);
} else {
this.cellLabel = localize('mdCellLabel', "Markdown Cell {0}", this.id);
}
this.createUri();
this.populatePropertiesFromSettings();
}

View File

@@ -499,6 +499,7 @@ export interface ITableUpdatedEvent {
export interface ICellModel {
cellUri: URI;
id: string;
cellLabel: string;
readonly language: string;
readonly displayLanguage: string;
readonly cellGuid: string;

View File

@@ -802,16 +802,18 @@ export class NotebookModel extends Disposable implements INotebookModel {
}
public updateActiveCell(cell?: ICellModel, isEditMode: boolean = false): void {
if (this._activeCell) {
this._activeCell.active = false;
this._activeCell.isEditMode = false;
if (this._activeCell !== cell) {
if (this._activeCell) {
this._activeCell.active = false;
this._activeCell.isEditMode = false;
}
this._activeCell = cell;
if (this._activeCell) {
this._activeCell.active = true;
this._activeCell.isEditMode = isEditMode;
}
this._onActiveCellChanged.fire(cell);
}
this._activeCell = cell;
if (this._activeCell) {
this._activeCell.active = true;
this._activeCell.isEditMode = isEditMode;
}
this._onActiveCellChanged.fire(cell);
}
public convertCellType(cell: ICellModel, addToUndoStack: boolean = true): void {