mdbootstrap / bootstrap-hover-dropdown

An unofficial Bootstrap plugin to enable Bootstrap dropdowns to activate on hover and provide a nice user experience.
http://cameronspear.com/demos/bootstrap-hover-dropdown/
MIT License
1.26k stars 503 forks source link

Fix issue#141. #157

Closed stormisover closed 7 years ago

stormisover commented 7 years ago

Use useAgent to detect device type instead of touch event.

jrchamp commented 7 years ago

The existing code takes the route of "feature detection" which is a more appropriate solution than "User Agent detection" (which is considered to be a bad practice).

If there are issues with the feature detection, please consider improving the feature detection mechanism.

jrchamp commented 7 years ago

According to Mozilla, navigator.userAgent is deprecated and has been removed from modern web standards: https://developer.mozilla.org/en-US/docs/Web/API/NavigatorID/userAgent

CWSpear commented 7 years ago

Yeah, I don't really like this solution.

The main problem here is indeed touch-enabled Windows machines. The only real solution I can find is the (not yet fully supported) Pointer Events.

See https://github.com/CWSpear/bootstrap-hover-dropdown/blob/3.0/bootstrap-hover-dropdown.js

It's impossible to create an automated test for this sort of thing as far as I can tell, and I don't have a way to manually test every browser/OS combo.

stormisover commented 7 years ago

I agree my solution are not nice enough because it has to enumerate all the OS name. However, I searched many solutions, this seems a common method.

For example, https://github.com/hgoebl/mobile-detect.js/

How could we bypass the mobile device perfectly?

CWSpear commented 7 years ago

The problem is we don't want to detect mobile. Or that is to say, that doesn't solve our issue. It's a complicated issues. That's why new technology at the browser level (Pointer Events) had to be created.

stormisover commented 7 years ago

Good to know. Thanks!