ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
50.97k stars 13.52k forks source link

feat: add a way to disable haptics in Ionic components #28719

Open aeharding opened 9 months ago

aeharding commented 9 months ago

Prerequisites

Describe the Feature Request

I would like an option to turn off Ionic's built-in haptics.

Describe the Use Case

Users would like an option to turn off all app haptics. Right now it is impossible to turn off Ionic's built-in haptics.

Describe Preferred Solution

setupIonicReact({ haptics: false })

Describe Alternatives

Not an alternative, but a complimentary feature request: it would be nice if Ionic emitted an ionHaptic event (or similar). Such an event would fire regardless of whether setupIonicReact({ haptics: false }) is configured or not. This would lets apps dynamically turn on/off haptics, use custom capacitor haptics libraries, and even disable haptics for certain components (with event.target).

Configuration Built-in haptics triggered? Ionic event triggered (ionHaptic)?
setupIonicReact({ haptics: true }) AKA default Yes Yes
setupIonicReact({ haptics: false }) No Yes

If Ionic is interested in this, I am happy to create a separate feature request.

Related Code

No response

Additional Information

https://github.com/aeharding/voyager/issues/1103

liamdebeasi commented 9 months ago

Thanks for the request. Can you help me understand why you'd like to disable the haptics?

aeharding commented 9 months ago

Thanks for the request. Can you help me understand why you'd like to disable the haptics?

This is a user request I've had a few times, mainly from Android users due to Android haptics being very inconsistent between vendors (and sometimes too strong or weak).

It is currently a setting you can change in Voyager, but only affects Voyager's custom haptics (hence this issue).

Edit: To be clear, disabling haptics is a setting in Voyager users can set if they don't like haptics for whatever reason. Only a small subset of users don't like haptics. Haptics are on by default.

liamdebeasi commented 9 months ago

Thanks for the added info. Is this a problem when changing the haptics preference via a system setting too? On https://github.com/aeharding/voyager/issues/1103 it sounded like turning haptics off in the Android Settings app wasn't actually disabling haptics.

I tested on my end and disabling haptics from the Settings app does disabled haptics.

aeharding commented 9 months ago

That user is referring to a Voyager app setting, not phone setting :)

liamdebeasi commented 9 months ago

Perfect, thanks! I think this is a good feature to have. The team has some concerns about placing this option in the IonicConfig (since the config is not reactive), so we'll need to do some design work first.