Skip to content

Fixes compressedNavigationController ends with outdated state after startup #86574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/vs/workbench/contrib/files/browser/views/explorerViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,30 @@ export class CompressedNavigationController implements ICompressedNavigationCont
static ID = 0;

private _index: number;
readonly labels: HTMLElement[];
private _labels!: HTMLElement[];
private _updateLabelDisposable: IDisposable;

get index(): number { return this._index; }
get count(): number { return this.items.length; }
get current(): ExplorerItem { return this.items[this._index]!; }
get currentId(): string { return `${this.id}_${this.index}`; }
get labels(): HTMLElement[] { return this._labels; }

private _onDidChange = new Emitter<void>();
readonly onDidChange = this._onDidChange.event;

constructor(private id: string, readonly items: ExplorerItem[], templateData: IFileTemplateData) {
this._index = items.length - 1;
this.labels = Array.from(templateData.container.querySelectorAll('.label-name')) as HTMLElement[];

for (let i = 0; i < items.length; i++) {
this.labels[i].setAttribute('aria-label', items[i].name);
this.updateLabels(templateData);
this._updateLabelDisposable = templateData.label.onDidRender(() => this.updateLabels(templateData));
}

private updateLabels(templateData: IFileTemplateData): void {
this._labels = Array.from(templateData.container.querySelectorAll('.label-name')) as HTMLElement[];

for (let i = 0; i < this.items.length; i++) {
this.labels[i].setAttribute('aria-label', this.items[i].name);
}

DOM.addClass(this.labels[this._index], 'active');
Expand Down Expand Up @@ -205,6 +213,7 @@ export class CompressedNavigationController implements ICompressedNavigationCont

dispose(): void {
this._onDidChange.dispose();
this._updateLabelDisposable.dispose();
}
}

Expand Down