-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Fix child menus for touch devices #666
Conversation
Add the ability to click on the parent once to access submenus, twice to access the parent item. Props @iamtakashi for the original fix.
* fixes #89 * from Automattic/_s#666 and Automattic/_s@d8d89bc
Defining a function and then immediately calling it seems not very elegant. It would also be great for it to have a better documentation than simply stating that it's a fix. Other than that is looks sound. :) |
touchStartFn = function( e ) { | ||
var menuItem = this.parentNode; | ||
|
||
if ( ! menuItem.classList.contains( 'focus' ) ) { |
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.
classList isn't supported in IE9 unfortunately, the usage stats look fairly low for that browser, but it might be worth using the classname.indexof method.
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.
I was wondering about that. But I doubt there'll be a lot of mobile devices running IE9 or below.
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.
Fair point, to clarify the issue applies to mobile and desktop IE9, but that is going to be a pretty tiny number of users
Takashi would know for sure, but I believe it's based on the jQuery fix in Twenty Twelve. |
@iamtakashi ^^ |
Yes. The idea is based on the fix in Twenty Twelve: https://core.trac.wordpress.org/ticket/24767 but it's converted to native Javascript. |
I only had iPad for testing. This works great in native Safari Browser but not in Chrome. I wonder if this is a bug in Chrome or in code. |
Hey @sixhours, when you get a chance, I'd love to see a refresh on this. I think addressing some of Obenland's feedback above would be great. Then we can test more thoroughly. I'm in favor of this getting in though. |
It's a bit over my head, honestly. If someone with more JS-fu wants to take a look at it, that'd be cool. |
This works for me in testing! We've also used it in many themes on WordPress.com with success. I'll see if I can resolve the conflicts and merge it. |
Oh good catch, I meant to grab from #900. Will create a new PR; closing this one to avoid confusion. |
Add the ability to click on the parent once to access submenus, twice
to access the parent item. Props @iamtakashi for the original fix.