mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-13 23:44:09 +01:00
@@ -808,7 +808,7 @@ export class TreeModel extends Events.EventEmitter {
|
||||
this.addEmitter2(this.registry),
|
||||
this.registry.addListener2('item:dispose', (event: IItemDisposeEvent) => {
|
||||
event.item.getAllTraits()
|
||||
.forEach(trait => this.removeTraits(trait, [event.item]));
|
||||
.forEach(trait => delete this.traitsToItems[trait][event.item.id]);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -1126,6 +1126,8 @@ export class TreeModel extends Events.EventEmitter {
|
||||
|
||||
public setFocus(element?: any, eventPayload?: any): void {
|
||||
this.setTraits('focused', element ? [element] : []);
|
||||
var eventData: _.IFocusEvent = { focus: this.getFocus(), payload: eventPayload };
|
||||
this.emit('focus', eventData);
|
||||
}
|
||||
|
||||
public isFocused(element: any): boolean {
|
||||
|
||||
@@ -330,10 +330,6 @@ export class ViewItem implements IViewItem {
|
||||
this.row = null;
|
||||
}
|
||||
|
||||
hasDOMFocus(): boolean {
|
||||
return this.row && this.row.element && DOM.isAncestor(document.activeElement, this.row.element);
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this.row = null;
|
||||
this.model = null;
|
||||
@@ -728,6 +724,9 @@ export class TreeView extends HeightMap implements IScrollable {
|
||||
case 'item:removeTrait':
|
||||
this.onItemRemoveTrait(data);
|
||||
break;
|
||||
case 'focus':
|
||||
this.onModelFocusChange();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1072,10 +1071,6 @@ export class TreeView extends HeightMap implements IScrollable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (e.trait === 'focused') {
|
||||
setTimeout(() => this.onModelFocusChange());
|
||||
}
|
||||
}
|
||||
|
||||
private onItemRemoveTrait(e:Model.IItemTraitEvent): void {
|
||||
@@ -1094,10 +1089,6 @@ export class TreeView extends HeightMap implements IScrollable {
|
||||
}
|
||||
delete this.highlightedItemWasDraggable;
|
||||
}
|
||||
|
||||
if (e.trait === 'focused') {
|
||||
setTimeout(() => this.onModelFocusChange());
|
||||
}
|
||||
}
|
||||
|
||||
private onModelFocusChange(): void {
|
||||
@@ -1610,10 +1601,6 @@ export class TreeView extends HeightMap implements IScrollable {
|
||||
}
|
||||
|
||||
private removeItemFromDOM(item: ViewItem): void {
|
||||
if (item.hasDOMFocus()) {
|
||||
this.focus();
|
||||
}
|
||||
|
||||
item.removeFromDOM();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user