Repository navigation
Description
Prerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
v8.x, v9.x
Current Behavior
If a sheet modal is dismissed while a breakpoint move is still animating, the move's completion callback calls gesture.enable(true) on a gesture that dismiss() has already destroyed.
createPointerEvents().destroy() sets pointerDown, pointerMove and pointerUp to undefined, but a later enable(true) still attaches the touchstart and mousedown listeners. For an inline modal the wrapper element is reused, so once the modal is presented again, every touch on the sheet throws from handleTouchStart in utils/gesture/pointer-events:
TypeError: pointerDown is not a function
In the minified builds the message is n is not a function (Chromium) or n is not a function. (In 'n(o)', 'n' is undefined) (WebKit).
The gesture created by the second present() works normally, so the sheet still drags and taps still reach their targets. The effect is an uncaught error on every touch for as long as that modal element lives.
Expected Behavior
A destroyed gesture stays disabled. No listener is attached after destroy(), and dismissing a sheet during a breakpoint move leaves nothing behind.
Steps to Reproduce
- Save the file below as
index.htmland open it with touch emulation on (or on a device). - Tap Run. It presents the sheet, moves it to breakpoint 1, then calls
setCurrentBreakpoint(0.4)without awaiting it and setsisOpen = falsestraight away. After the dismiss it presents the sheet again. - Tap Tap me, or anywhere on the sheet. Each
touchstartlogs the error above.
Awaiting setCurrentBreakpoint(0.4) before dismissing gives no errors.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core@8.8.20/css/ionic.bundle.css">
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core@8.8.20/dist/ionic/ionic.esm.js"></script>
</head>
<body>
<ion-app>
<ion-content class="ion-padding">
<ion-button id="run">Run</ion-button>
</ion-content>
<ion-modal id="sheet">
<div class="ion-page">
<ion-content class="ion-padding"><ion-button id="tap">Tap me</ion-button></ion-content>
</div>
</ion-modal>
</ion-app>
<script>
const sheet = document.getElementById('sheet');
sheet.breakpoints = [0, 0.4, 1];
sheet.initialBreakpoint = 0.4;
const once = (name) => new Promise((resolve) => sheet.addEventListener(name, resolve, { once: true }));
document.getElementById('run').addEventListener('click', async () => {
sheet.isOpen = true;
await once('didPresent');
await sheet.setCurrentBreakpoint(1);
sheet.setCurrentBreakpoint(0.4); // not awaited
sheet.isOpen = false; // dismiss while the move is animating
await once('didDismiss');
await new Promise((resolve) => setTimeout(resolve, 800));
sheet.isOpen = true;
await once('didPresent');
// Now touch "Tap me" (or anywhere on the sheet): each touchstart throws.
});
</script>
</body>
</html>Results with headless Playwright (touch enabled, 390x844), three taps after the second present:
@ionic/core |
Chromium | WebKit |
|---|---|---|
| 8.7.17 | 3 errors | 1 error |
| 8.8.20 | 3 errors | 1 error |
| 9.0.12 | 3 errors | 1 error |
No errors are thrown before the first tap. WebKit reports one error for the three taps; I have not looked into why it differs from Chromium.
Code Reproduction URL
Single-file reproduction is inline above (it loads @ionic/core from jsDelivr). I can move it to a repository if that is needed.
Ionic Info
@ionic/core only, no framework.
@ionic/core : 8.7.17, 8.8.20, 9.0.12
Browsers : Playwright 1.64 Chromium and WebKit, headless
OS : macOS
Additional Information
Where it happens:
core/src/components/modal/gestures/sheet.ts:moveSheetToBreakpointdisables the gesture for the snap animation and callsgesture.enable(true)when it finishes, without checking that the modal is still presented.core/src/components/modal/modal.tsx:dismiss()callsthis.gesture.destroy(), which can run before that animation finishes.core/src/utils/gesture/pointer-events.ts:destroy()clears the callbacks, butenable(true)still adds listeners afterwards.
Possible fix: keep a destroyed flag in createPointerEvents so that enable(true) does nothing after destroy(). That would also cover the keyboard-open callback in modal.tsx, which re-enables the gesture on the next frame.
We see this in production in an app where a sheet is moved between breakpoints and can be dismissed by another event a moment later.
Activity
aliassar commentedon Nov 19, 2026
I looked into this and the cause is as you describe:
destroy()clears the pointer handlers inpointer-events.ts, but a laterenable(true)(from the sheet moveonFinishafter dismiss) still re-adds thetouchstart/mousedownlisteners. I have a small fix that makesenable()a no-op once the gesture is destroyed, with a spec test, and would be happy to open a PR if that works for you.thetaPC commentedon Nov 19, 2026
Thanks for the report, and for the detailed reproduction.
Verified on 9.0.12. When
setCurrentBreakpoint()finishes in the same frame that the dismiss tears the sheet gesture down, its completion callback runs one frame later and turns the destroyed gesture back on. The modal element is reused on the next present, so the dead listeners stay attached to it. This also affects mouse clicks on desktop, not only touches. Each dismiss that hits this timing adds another dead listener, so the number of errors per touch grows over the life of the app.Workaround, verified on 9.0.12: wait for the breakpoint move to finish before dismissing. If the dismiss comes from somewhere else in your app, keep the pending move and await it first:
Tracked as a bug in
core.[-]bug: modal: sheet gesture is re-enabled after dismiss, every later touch throws "pointerDown is not a function"[/-][+]bug: ion-modal sheet throws "pointerDown is not a function" on touch[/+]