mirror of
https://github.com/mathuo/dockview
synced 2025-05-01 09:08:24 +00:00
Merge pull request #27 from mathuo/23-increase-test-coverage
feat: dispose of event listeners
This commit is contained in:
commit
cd33a753d6
@ -50,6 +50,12 @@ export class GridviewPanelApiImpl
|
||||
|
||||
constructor(id: string) {
|
||||
super(id);
|
||||
|
||||
this.addDisposables(
|
||||
this._onDidConstraintsChangeInternal,
|
||||
this._onDidConstraintsChange,
|
||||
this._onDidSizeChange
|
||||
);
|
||||
}
|
||||
|
||||
public setConstraints(value: GridConstraintChangeEvent) {
|
||||
|
@ -69,6 +69,12 @@ export class DockviewPanelApiImpl
|
||||
constructor(private panel: IGroupPanel, group: GroupviewPanel | undefined) {
|
||||
super(panel.id);
|
||||
this._group = group;
|
||||
|
||||
this.addDisposables(
|
||||
this._onDidTitleChange,
|
||||
this._titleChanged,
|
||||
this._suppressClosableChanged
|
||||
);
|
||||
}
|
||||
|
||||
public setTitle(title: string) {
|
||||
@ -85,8 +91,4 @@ export class DockviewPanelApiImpl
|
||||
public interceptOnCloseAction(interceptor: () => Promise<boolean>) {
|
||||
this._interceptor = interceptor;
|
||||
}
|
||||
|
||||
public dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
@ -126,6 +126,8 @@ export class PanelApiImpl extends CompositeDisposable implements PanelApi {
|
||||
this._onDidVisibilityChange,
|
||||
this._onDidActiveChange,
|
||||
this._onFocusEvent,
|
||||
this._onActiveChange,
|
||||
this._onVisibilityChange,
|
||||
this.onDidFocusChange((event) => {
|
||||
this._isFocused = event.isFocused;
|
||||
}),
|
||||
|
@ -37,6 +37,12 @@ export class PaneviewPanelApiImpl
|
||||
|
||||
constructor(id: string) {
|
||||
super(id);
|
||||
|
||||
this.addDisposables(
|
||||
this._onDidExpansionChange,
|
||||
this._onMouseEnter,
|
||||
this._onMouseLeave
|
||||
);
|
||||
}
|
||||
|
||||
setExpanded(isExpanded: boolean): void {
|
||||
|
@ -47,6 +47,12 @@ export class SplitviewPanelApiImpl
|
||||
|
||||
constructor(id: string) {
|
||||
super(id);
|
||||
|
||||
this.addDisposables(
|
||||
this._onDidConstraintsChangeInternal,
|
||||
this._onDidConstraintsChange,
|
||||
this._onDidSizeChange
|
||||
);
|
||||
}
|
||||
|
||||
setConstraints(value: PanelConstraintChangeEvent2) {
|
||||
@ -56,10 +62,4 @@ export class SplitviewPanelApiImpl
|
||||
setSize(event: PanelSizeEvent) {
|
||||
this._onDidSizeChange.fire(event);
|
||||
}
|
||||
|
||||
dispose() {
|
||||
super.dispose();
|
||||
this._onDidConstraintsChange.dispose();
|
||||
this._onDidSizeChange.dispose();
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ export abstract class DragHandler extends CompositeDisposable {
|
||||
|
||||
private configure() {
|
||||
this.addDisposables(
|
||||
this._onDragStart,
|
||||
addDisposableListener(this.el, 'dragstart', (event) => {
|
||||
this.iframes = [
|
||||
...getElementsByTagName('iframe'),
|
||||
|
@ -56,6 +56,7 @@ export class Droptarget extends CompositeDisposable {
|
||||
super();
|
||||
|
||||
this.addDisposables(
|
||||
this._onDrop,
|
||||
new DragAndDropObserver(this.element, {
|
||||
onDragEnter: (e) => undefined,
|
||||
onDragOver: (e) => {
|
||||
@ -177,7 +178,6 @@ export class Droptarget extends CompositeDisposable {
|
||||
}
|
||||
|
||||
public dispose() {
|
||||
this._onDrop.dispose();
|
||||
this.removeDropTarget();
|
||||
}
|
||||
|
||||
|
@ -186,6 +186,12 @@ export class DockviewComponent
|
||||
styles: options.styles,
|
||||
});
|
||||
|
||||
this.addDisposables(
|
||||
this._onTabInteractionEvent,
|
||||
this._onTabContextMenu,
|
||||
this._onDidDrop
|
||||
);
|
||||
|
||||
this._options = options;
|
||||
|
||||
if (!this.options.components) {
|
||||
@ -719,15 +725,6 @@ export class DockviewComponent
|
||||
return view;
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
super.dispose();
|
||||
|
||||
this._onGridEvent.dispose();
|
||||
this._onDidDrop.dispose();
|
||||
this._onTabContextMenu.dispose();
|
||||
this._onTabInteractionEvent.dispose();
|
||||
}
|
||||
|
||||
private _addPanel(options: AddPanelOptions): IGroupPanel {
|
||||
const view = new DefaultGroupPanelView({
|
||||
content: this.createContentComponent(options.id, options.component),
|
||||
|
@ -155,6 +155,7 @@ export class BranchNode extends CompositeDisposable implements IView {
|
||||
}
|
||||
|
||||
this.addDisposables(
|
||||
this._onDidChange,
|
||||
this.splitview.onDidSashEnd(() => {
|
||||
this._onDidChange.fire(undefined);
|
||||
})
|
||||
|
@ -129,6 +129,7 @@ export abstract class GridviewPanel
|
||||
super(id, component, api);
|
||||
|
||||
this.addDisposables(
|
||||
this._onDidChange,
|
||||
this.api.onVisibilityChange((event) => {
|
||||
const { isVisible } = event;
|
||||
const { containerApi } = this._params as GridviewInitParameters;
|
||||
@ -230,10 +231,6 @@ export abstract class GridviewPanel
|
||||
priority: this.priority,
|
||||
};
|
||||
}
|
||||
|
||||
dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
export interface GridPanelViewState extends BasePanelViewState {
|
||||
|
@ -128,6 +128,7 @@ export class LeafNode implements IView {
|
||||
}
|
||||
|
||||
public dispose() {
|
||||
this._onDidChange.dispose();
|
||||
this._disposable.dispose();
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,8 @@ export class ContentContainer
|
||||
this._element.className = 'content-container';
|
||||
this._element.tabIndex = -1;
|
||||
|
||||
this.addDisposables(this._onDidFocus, this._onDidBlur);
|
||||
|
||||
// for hosted containers
|
||||
// 1) register a drop target on the host
|
||||
// 2) register window dragStart events to disable pointer events
|
||||
|
@ -95,6 +95,7 @@ export class Paneview extends CompositeDisposable implements IDisposable {
|
||||
});
|
||||
|
||||
this.addDisposables(
|
||||
this._onDidChange,
|
||||
this.splitview.onDidSashEnd(() => {
|
||||
this._onDidChange.fire(undefined);
|
||||
}),
|
||||
|
@ -185,6 +185,13 @@ export class PaneviewComponent
|
||||
) {
|
||||
super();
|
||||
|
||||
this.addDisposables(
|
||||
this._onDidLayoutChange,
|
||||
this._onDidDrop,
|
||||
this._onDidAddView,
|
||||
this._onDidRemoveView
|
||||
);
|
||||
|
||||
this._options = options;
|
||||
|
||||
if (!options.components) {
|
||||
|
@ -124,6 +124,8 @@ export class ReactPanelContentPart implements IContentRenderer {
|
||||
}
|
||||
|
||||
public dispose() {
|
||||
this._onDidFocus.dispose();
|
||||
this._onDidBlur.dispose();
|
||||
this.part?.dispose();
|
||||
// this.hostedContainer?.dispose();
|
||||
this.actionsPart?.dispose();
|
||||
|
@ -168,7 +168,12 @@ export class SplitviewComponent
|
||||
|
||||
this.splitview = new Splitview(this.element, options);
|
||||
|
||||
this.addDisposables(this._disposable);
|
||||
this.addDisposables(
|
||||
this._disposable,
|
||||
this._onDidAddView,
|
||||
this._onDidRemoveView,
|
||||
this._onDidLayoutChange
|
||||
);
|
||||
}
|
||||
|
||||
updateOptions(options: Partial<SplitviewComponentUpdateOptions>): void {
|
||||
|
@ -82,6 +82,7 @@ export abstract class SplitviewPanel
|
||||
super(id, componentName, new SplitviewPanelApiImpl(id));
|
||||
|
||||
this.addDisposables(
|
||||
this._onDidChange,
|
||||
this.api.onVisibilityChange((event) => {
|
||||
const { isVisible } = event;
|
||||
const { containerApi } = this
|
||||
|
Loading…
Reference in New Issue
Block a user