feat: general cleanup

This commit is contained in:
mathuo 2021-10-20 23:19:20 +01:00
parent ee22a08b2e
commit 3b35997b2f
No known key found for this signature in database
GPG Key ID: C6EEDEFD6CA07281
6 changed files with 14 additions and 19 deletions

View File

@ -20,5 +20,7 @@ describe('lifecycle', () => {
mutableDisposable.dispose();
expect(disposed).toBe(2);
mutableDisposable.dispose();
});
});

View File

@ -94,6 +94,8 @@ export class DefaultTab extends CompositeDisposable implements ITabRenderer {
constructor() {
super();
this.addDisposables(this.isDirtyDisposable);
this._element = document.createElement('div');
this._element.className = 'default-tab';
//

View File

@ -1,8 +1,11 @@
export const focusedElement: { element: Element | null } = { element: null };
//TODO somebody could call .stopPropagation() on this - can you do this at the event capture-stage instead?
window.addEventListener('focusin', () => {
focusedElement.element = document.activeElement;
});
window.addEventListener(
'focusin',
() => {
focusedElement.element = document.activeElement;
},
true
);
focusedElement.element = document.activeElement;

View File

@ -275,6 +275,7 @@ export class Gridview implements IDisposable {
}
public dispose() {
this.disposable.dispose();
this._onDidChange.dispose();
this.root.dispose();
}

View File

@ -115,20 +115,7 @@ export class Tab extends CompositeDisposable implements ITab {
*/
event.stopPropagation();
/**
* //TODO mousedown focusing with draggable element (is there a better approach?)
*
* this mousedown event wants to focus the tab itself but if we call preventDefault()
* this would also prevent the dragStart event from firing. To get around this we propagate
* the onChanged event during the next tick of the event-loop, allowing the tab element to become
* focused on this tick and ensuring the dragstart event is not interrupted
*/
const oldFocus = focusedElement.element as HTMLElement;
setTimeout(() => {
oldFocus.focus();
this._onChanged.fire({ kind: MouseEventKind.CLICK, event });
}, 0);
this._onChanged.fire({ kind: MouseEventKind.CLICK, event });
}),
addDisposableListener(this._element, 'contextmenu', (event) => {
this._onChanged.fire({

View File

@ -279,7 +279,7 @@ export class SplitviewComponent
return;
}
const { width, height } =
this.element.parentElement?.getBoundingClientRect();
this.element.parentElement.getBoundingClientRect();
this.layout(width, height);
}