Clean up dialog event hide reasons (#14566)

* Clean up dialog event hide reasons

* Remove done
This commit is contained in:
Charles Gagnon
2021-03-05 08:54:35 -08:00
committed by GitHub
parent 21019f7452
commit d2faf9075d
21 changed files with 67 additions and 58 deletions

View File

@@ -104,6 +104,8 @@ const defaultOptions: IModalOptions = {
const tabbableElementsQuerySelector = 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]';
export type HideReason = 'close' | 'cancel' | 'ok';
export abstract class Modal extends Disposable implements IThemable {
protected _useDefaultMessageBoxLocation: boolean = true;
protected _messageElement?: HTMLElement;
@@ -317,7 +319,7 @@ export abstract class Modal extends Disposable implements IThemable {
* Overridable to change behavior of escape key
*/
protected onClose(e?: StandardKeyboardEvent) {
this.hide();
this.hide('close');
}
/**
@@ -330,7 +332,7 @@ export abstract class Modal extends Disposable implements IThemable {
if (target.closest('.modal-content')) {
return;
} else {
this.hide();
this.hide('close');
}
}
@@ -338,7 +340,7 @@ export abstract class Modal extends Disposable implements IThemable {
* Overridable to change behavior of enter key
*/
protected onAccept(e?: StandardKeyboardEvent) {
this.hide();
this.hide('ok');
}
private handleBackwardTab(e: KeyboardEvent) {
@@ -499,7 +501,7 @@ export abstract class Modal extends Disposable implements IThemable {
/**
* Hides the modal and removes key listeners
*/
protected hide(reason?: string, currentPageName?: string): void {
protected hide(reason?: HideReason, currentPageName?: string): void {
this._modalShowingContext.get()!.pop();
this._bodyContainer!.remove();
this.disposableStore.clear();