Skip to content

Commit 796e007

Browse files
jedlikowskithetaPCShaneK
authored
feat(toggle): add iOS 18 haptic feedback (#29945)
Co-authored-by: Maria Hutt <[email protected]> Co-authored-by: Shane <[email protected]>
1 parent 91477cf commit 796e007

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

core/src/components/toggle/toggle.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Component, Element, Event, Host, Prop, State, Watch, h } from '@stencil
33
import { renderHiddenInput, inheritAriaAttributes } from '@utils/helpers';
44
import type { Attributes } from '@utils/helpers';
55
import { hapticSelection } from '@utils/native/haptic';
6+
import { isPlatform } from '@utils/platform';
67
import { isRTL } from '@utils/rtl';
78
import { createColorClasses, hostContext } from '@utils/theme';
89
import { checkmarkOutline, removeOutline, ellipseOutline } from 'ionicons/icons';
@@ -247,6 +248,13 @@ export class Toggle implements ComponentInterface {
247248
}
248249

249250
private onClick = (ev: MouseEvent) => {
251+
/**
252+
* The haptics for the toggle on tap is
253+
* an iOS-only feature. As such, it should
254+
* only trigger on iOS.
255+
*/
256+
const enableHaptics = isPlatform('ios');
257+
250258
if (this.disabled) {
251259
return;
252260
}
@@ -255,6 +263,7 @@ export class Toggle implements ComponentInterface {
255263

256264
if (this.lastDrag + 300 < Date.now()) {
257265
this.toggleChecked();
266+
enableHaptics && hapticSelection();
258267
}
259268
};
260269

0 commit comments

Comments
 (0)