mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-09 08:09:32 +08:00
fix(modal): keyboard listener removed on dismiss (#26856)
This commit is contained in:
@ -333,7 +333,7 @@ export class Modal implements ComponentInterface, OverlayInterface {
|
|||||||
if (this.gesture) {
|
if (this.gesture) {
|
||||||
this.gesture.enable(enable);
|
this.gesture.enable(enable);
|
||||||
} else if (enable) {
|
} else if (enable) {
|
||||||
await this.initSwipeToClose();
|
this.initSwipeToClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -532,6 +532,38 @@ export class Modal implements ComponentInterface, OverlayInterface {
|
|||||||
backdropBreakpoint: this.backdropBreakpoint,
|
backdropBreakpoint: this.backdropBreakpoint,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* tslint:disable-next-line */
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
/**
|
||||||
|
* This needs to be setup before any
|
||||||
|
* non-transition async work so it can be dereferenced
|
||||||
|
* in the dismiss method. The dismiss method
|
||||||
|
* only waits for the entering transition
|
||||||
|
* to finish. It does not wait for all of the `present`
|
||||||
|
* method to resolve.
|
||||||
|
*/
|
||||||
|
this.keyboardOpenCallback = () => {
|
||||||
|
if (this.gesture) {
|
||||||
|
/**
|
||||||
|
* When the native keyboard is opened and the webview
|
||||||
|
* is resized, the gesture implementation will become unresponsive
|
||||||
|
* and enter a free-scroll mode.
|
||||||
|
*
|
||||||
|
* When the keyboard is opened, we disable the gesture for
|
||||||
|
* a single frame and re-enable once the contents have repositioned
|
||||||
|
* from the keyboard placement.
|
||||||
|
*/
|
||||||
|
this.gesture.enable(false);
|
||||||
|
raf(() => {
|
||||||
|
if (this.gesture) {
|
||||||
|
this.gesture.enable(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
window.addEventListener(KEYBOARD_DID_OPEN, this.keyboardOpenCallback);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO (FW-937) - In the next major release of Ionic, all card modals
|
* TODO (FW-937) - In the next major release of Ionic, all card modals
|
||||||
* will be swipeable by default. canDismiss will be used to determine if the
|
* will be swipeable by default. canDismiss will be used to determine if the
|
||||||
@ -559,31 +591,7 @@ export class Modal implements ComponentInterface, OverlayInterface {
|
|||||||
if (this.isSheetModal) {
|
if (this.isSheetModal) {
|
||||||
this.initSheetGesture();
|
this.initSheetGesture();
|
||||||
} else if (hasCardModal) {
|
} else if (hasCardModal) {
|
||||||
await this.initSwipeToClose();
|
this.initSwipeToClose();
|
||||||
}
|
|
||||||
|
|
||||||
/* tslint:disable-next-line */
|
|
||||||
if (typeof window !== 'undefined') {
|
|
||||||
this.keyboardOpenCallback = () => {
|
|
||||||
if (this.gesture) {
|
|
||||||
/**
|
|
||||||
* When the native keyboard is opened and the webview
|
|
||||||
* is resized, the gesture implementation will become unresponsive
|
|
||||||
* and enter a free-scroll mode.
|
|
||||||
*
|
|
||||||
* When the keyboard is opened, we disable the gesture for
|
|
||||||
* a single frame and re-enable once the contents have repositioned
|
|
||||||
* from the keyboard placement.
|
|
||||||
*/
|
|
||||||
this.gesture.enable(false);
|
|
||||||
raf(() => {
|
|
||||||
if (this.gesture) {
|
|
||||||
this.gesture.enable(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
window.addEventListener(KEYBOARD_DID_OPEN, this.keyboardOpenCallback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currentTransition = undefined;
|
this.currentTransition = undefined;
|
||||||
@ -725,6 +733,7 @@ export class Modal implements ComponentInterface, OverlayInterface {
|
|||||||
/* tslint:disable-next-line */
|
/* tslint:disable-next-line */
|
||||||
if (typeof window !== 'undefined' && this.keyboardOpenCallback) {
|
if (typeof window !== 'undefined' && this.keyboardOpenCallback) {
|
||||||
window.removeEventListener(KEYBOARD_DID_OPEN, this.keyboardOpenCallback);
|
window.removeEventListener(KEYBOARD_DID_OPEN, this.keyboardOpenCallback);
|
||||||
|
this.keyboardOpenCallback = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user