mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-28 17:23:19 -05:00
Add onClosed event to ModelView dialogs (#17531)
* Add onClosed event to ModelView dialogs * Use defined type * Fix compile * fix tests * fix tests2 * Remove unused
This commit is contained in:
@@ -29,6 +29,7 @@ import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { attachButtonStyler } from 'vs/platform/theme/common/styler';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
|
||||
export enum MessageLevel {
|
||||
Error = 0,
|
||||
@@ -147,6 +148,9 @@ export abstract class Modal extends Disposable implements IThemable {
|
||||
private _modalShowingContext: IContextKey<Array<string>>;
|
||||
private readonly _staticKey: string;
|
||||
|
||||
private _onClosed = new Emitter<HideReason>();
|
||||
public onClosed = this._onClosed.event;
|
||||
|
||||
/**
|
||||
* Get the back button, only available after render and if the hasBackButton option is true
|
||||
*/
|
||||
@@ -458,7 +462,7 @@ export abstract class Modal extends Disposable implements IThemable {
|
||||
}
|
||||
}));
|
||||
this.disposableStore.add(trapKeyboardNavigation(this._modalDialog!));
|
||||
this.disposableStore.add(DOM.addDisposableListener(window, DOM.EventType.RESIZE, (e: Event) => {
|
||||
this.disposableStore.add(DOM.addDisposableListener(window, DOM.EventType.RESIZE, e => {
|
||||
this.layout(DOM.getTotalHeight(this._modalBodySection!));
|
||||
}));
|
||||
|
||||
@@ -476,7 +480,7 @@ export abstract class Modal extends Disposable implements IThemable {
|
||||
/**
|
||||
* Hides the modal and removes key listeners
|
||||
*/
|
||||
protected hide(reason?: HideReason, currentPageName?: string): void {
|
||||
protected hide(reason: HideReason = 'close', currentPageName?: string): void {
|
||||
this._modalShowingContext.get()!.pop();
|
||||
this._bodyContainer!.remove();
|
||||
this.disposableStore.clear();
|
||||
@@ -488,6 +492,7 @@ export abstract class Modal extends Disposable implements IThemable {
|
||||
})
|
||||
.send();
|
||||
this.restoreKeyboardFocus();
|
||||
this._onClosed.fire(reason);
|
||||
}
|
||||
|
||||
private restoreKeyboardFocus() {
|
||||
|
||||
Reference in New Issue
Block a user