-
Notifications
You must be signed in to change notification settings - Fork 13.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(toggle): add iOS 18 haptic feedback #29945
base: main
Are you sure you want to change the base?
feat(toggle): add iOS 18 haptic feedback #29945
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -312,7 +343,8 @@ export class Toggle implements ComponentInterface { | |||
[`toggle-${rtl}`]: true, | |||
})} | |||
> | |||
<label class="toggle-wrapper"> | |||
{this.renderFallbackHapticElements()} | |||
<label class="toggle-wrapper" onClick={this.onClick}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onClick
listener moved to label, without this change Host
was capturing clicks on the haptic <label>
too, not only on .toggle-wrapper
const { inputId } = this; | ||
const mode = getIonMode(this); | ||
|
||
if (hapticAvailable() || mode !== 'ios') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, we don't need these elements if Vibration API is available, because then hapticSelection()
will work.
Hi @thetaPC, could you take a look? Do you have any suggestions? Or can we get this merged? Can't wait to have haptic feedback on toggles in my PWA 😄 |
Issue number: resolves #29942
What is the current behavior?
Safari on iOS doesn't support vibration API and it might never do: WebKit/standards-positions#267. However, as described in the issue, since iOS 18 we can use a special
<input type=checkbox switch>
element to bring haptic feedback to PWAs by triggering a click on this input's label.What is the new behavior?
<label>
with<input type=checkbox switch>
insideDoes this introduce a breaking change?
Other information
No visual changes, just slight haptic feedback when changing Toggle state on iOS 18+