Skip to content

[896] Add onDidBlockPopout event #927

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
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions packages/dockview-core/src/api/component.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,10 @@ export class DockviewApi implements CommonApi<SerializedDockview> {
return this.component.onDidPopoutGroupPositionChange;
}

get onDidBlockPopout(): Event<void> {
return this.component.onDidBlockPopout;
}

/**
* All panel objects.
*/
Expand Down
8 changes: 7 additions & 1 deletion packages/dockview-core/src/dockview/dockviewComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ export interface IDockviewComponent extends IBaseGrid<DockviewGroupPanel> {
readonly onDidMaximizedGroupChange: Event<DockviewMaximizedGroupChanged>;
readonly onDidPopoutGroupSizeChange: Event<PopoutGroupChangeSizeEvent>;
readonly onDidPopoutGroupPositionChange: Event<PopoutGroupChangePositionEvent>;
readonly onDidBlockPopout: Event<void>;
readonly options: DockviewComponentOptions;
updateOptions(options: DockviewOptions): void;
moveGroupOrPanel(options: MoveGroupOrPanelOptions): void;
Expand Down Expand Up @@ -319,6 +320,9 @@ export class DockviewComponent
readonly onDidPopoutGroupPositionChange: Event<PopoutGroupChangePositionEvent> =
this._onDidPopoutGroupPositionChange.event;

private readonly _onDidBlockPopout = new Emitter<void>();
readonly onDidBlockPopout: Event<void> = this._onDidBlockPopout.event;

private readonly _onDidLayoutFromJSON = new Emitter<void>();
readonly onDidLayoutFromJSON: Event<void> = this._onDidLayoutFromJSON.event;

Expand Down Expand Up @@ -505,6 +509,7 @@ export class DockviewComponent
this._onDidOptionsChange,
this._onDidPopoutGroupSizeChange,
this._onDidPopoutGroupPositionChange,
this._onDidBlockPopout,
this.onDidViewVisibilityChangeMicroTaskQueue(() => {
this.updateWatermark();
}),
Expand Down Expand Up @@ -715,6 +720,7 @@ export class DockviewComponent

if (popoutContainer === null) {
popoutWindowDisposable.dispose();
this._onDidBlockPopout.fire();
return false;
}

Expand All @@ -734,7 +740,7 @@ export class DockviewComponent
const referenceLocation = itemToPopout.api.location.type;

/**
* The group that is being added doesn't already exist within the DOM, the most likely occurance
* The group that is being added doesn't already exist within the DOM, the most likely occurrence
* of this case is when being called from the `fromJSON(...)` method
*/
const isGroupAddedToDom =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ export const App = (props: { theme?: string }) => {

const load = (api: DockviewApi) => {
api.clear();
api.onDidBlockPopout(() => {
console.log('Popout blocked');
});
if (layout) {
try {
api.fromJSON(layout);
Expand Down