Revert "fixes #3294"

This reverts commit 16a8d1d12f.
This commit is contained in:
Benjamin Pasero
2016-03-09 15:43:47 +01:00
parent 0af2119bbd
commit 1fb842763a
2 changed files with 6 additions and 17 deletions
+3 -1
View File
@@ -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 {
+3 -16
View File
@@ -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();
}