Skip to content

feat(haptics): add a cancelable ionHaptic event - #31812

Open
ShaneK wants to merge 6 commits into
feature-9.1from
FW-7943
Open

ShaneK wants to merge 6 commits into
feature-9.1from
FW-7943

Conversation

@ShaneK

@ShaneK ShaneK commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Issue number: #28719 - this was split into two PRs. This one and #31724 should cover the entire issue


What is the current behavior?

Currently, apps can't tell when an Ionic component plays a haptic. The haptics config can turn them all off, but there's no way to skip a single one, swap it for a different haptic, or play your own in its place.

What is the new behavior?

Components now dispatch a bubbling, cancelable ionHaptic event from their host element right before they play a haptic. The detail.type matches the Capacitor Haptics method we'd call (selectionStart, impact, etc.), with style or notificationType included for impacts and notifications. Calling preventDefault() skips the built-in haptic for that event. The event still fires when haptics is false or the Haptics plugin isn't installed, so an app can turn ours off and play its own.

selectionEnd is the one exception. It doesn't play anything and only releases the haptic engine, so we always run it even when the event is canceled. If we didn't, canceling only selectionEnd would leave the engine started, and the next gesture's selectionChanged would play even if that gesture's selectionStart had been canceled.

HapticEvent and HapticEventDetail are exported from core and the Angular, React and Vue packages, the same way BackButtonEvent is.

Does this introduce a breaking change?

  • Yes
  • No

The haptic helpers now take the host element, but they aren't exported publicly, so nothing outside core calls them. This is a new feature, which is why it's pointed at feature-9.1.

Other information

ionHaptic isn't a Stencil @Event, so it won't show up in the component API tables or the framework prop types. Binding @ionHaptic on a component in Vue doesn't fire because Vue hyphenates the name to ion-haptic, so the docs show adding a listener on document instead. That docs PR is in progress on the FW-7943 branch, here: ionic-team/ionic-docs#4892

The event only fires where a component would play a haptic, so a toggle tap and the picker column still only dispatch it on iOS.

@ShaneK
ShaneK requested a review from a team as a code owner November 23, 2026 20:10
@ShaneK
ShaneK requested a review from thetaPC November 23, 2026 20:10
@vercel

vercel Bot commented Nov 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ionic-framework Ready Ready Preview Nov 23, 2026 8:10pm UTC

Request Review

@github-actions github-actions Bot added package: core @ionic/core package package: angular @ionic/angular package package: vue @ionic/vue package package: react @ionic/react package labels Nov 23, 2026

This branch was successfully deployed

1 active deployment
Preview — ca633312 Deployed Nov 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: angular @ionic/angular package package: core @ionic/core package package: react @ionic/react package package: vue @ionic/vue package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant