Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#21678 closed defect (bug) (worksforme)

Twenty Twelve: gracefully handle displaying sub-menus in small navigation menu

Reported by: lancewillett Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Bundled Theme Keywords:
Focuses: Cc:


Drew's design for the mobile view of this theme calls for a centered title, description, and menu.

Recently I tried to introduce a hierarchy to show the sub-menu items in the same list. See r21564.


Discussing in IRC today Nacin and others commented it's awkward to see indented items in a centered list.

Ideas to improve:

  1. Don't show sub-menus in small navigation
  2. Use a leading indicator, like an em-dash, to denote the hierarchy
  3. Rework the layout to not use a centered navigation elements

Change History (11)

#1 @lancewillett
9 years ago

I'm personally voting for 1. The only drawback I see is site owners can't show their entire menu to mobile visitors. Otherwise it's clean and simple, and stays true to the design vision.

#2 @lancewillett
9 years ago

Talked this over with Drew today—his goal was to show *all* menu items but without any hierarchy. That way there is nothing hidden, good for usability, but no indents to throw off the visual look.

In the end, somebody with a massive menu is going to have lots of items, but that's why we're hiding it by default.

The centered look is by design, and we'd like to keep it. (Acknowledging that the indented list looked pretty weird, though.)

#3 @drewstrojny
9 years ago

I played with this and really couldn't come up with anything I liked using CSS3 columns and I'm not a fan of option number 2.

I agree with Nacin, the menu isn't the best use of space if you have a ton of menu items, but it's really the only good way we can handle it right now. I'd vote we just stick with a centered navigation for all menu items and ignore indenting sub-menu items. I'd also be OK with hiding sub-menu items, but would prefer just including them centered.

I'm also quite open to suggestions and patches if someone has a good solution in mind for option number 3.

#4 follow-up: @emiluzelac
9 years ago

  • Cc emil@… added

Good approach to this is to get the menu act and be like dropdown (select) box, this way you will avoid centered menu and reduce so much unnecessary space.

Take a look at TinyNav.js

and slightly modify active for current items and voila!

// Responsive Menu (TinyNav.js)
    active: 'current_page_item', // Set the "active" class
    header: false // Show header instead of the active item

I tried showing all by default, users didn't like it, after that it was nice and centered, still many support questions "why oh why" and after Theme incorporated TinyNav.js everyone liked it.

And if you guys don't like that idea you can always use current setup and adjusted to be more like this RWD Nav Patterns

P.S. Keeping main menu only is great idea.


#5 in reply to: ↑ 4 @lancewillett
9 years ago

Replying to emiluzelac:

Good approach to this is to get the menu act and be like dropdown (select) box, this way you will avoid centered menu and reduce so much unnecessary space.

Take a look at TinyNav.js

That approach looks cool, though weird that it looks like a form element since that's not the exact interaction here.

Also, we aren't loading jQuery on the front-end at all, so we'd need a pure JS solution.

#6 @lancewillett
9 years ago

What do you think about having a new menu location in this theme for mobile / small devices?

That way if the user makes a trimmed-down menu and assigns it to that specific location they can choose how simple or complex to show it.

The trick is the fallback. If they don't assign a menu to that location, it'd go to wp_page_menu() which probably isn't a great idea.

#7 @emiluzelac
9 years ago

I styled mine to look like this but if you guys don't want jQuery on front-end that's different story, I didn't know :)

New menu location for mobile devices? Wow, that's actually pretty cool idea. And it wouldn't be that difficult to implement, because you guys can easily assign "mobile" class to it and the only thing left after that is some logic when the menu will turn on, I mean "break" in Media Queries.

#8 @lancewillett
9 years ago

Another example of a mobile menu that displays all children in hierarchy is "Minileven" -- a mobile theme we use on that replaced WPTouch.

Example, menu open:

Example, menu closed:

In behavior it's very similar to Twenty Twelve, though styled to be left-aligned and show a search bar also.

#9 @lancewillett
9 years ago

Test out Minileven at this test site: With Safari just change the user agent from the Developer > User Agent menu to iPhone to see it on your desktop. Or go to that URL on a mobile device.

#10 @lancewillett
9 years ago

  • Keywords ui-feedback removed
  • Milestone 3.5 deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Looking at this more and thinking about the complexity, though there is room for improvement, the default styles work really well for the majority of cases where a small amount of navigation items are in the site menu.

For the cases with huge menus we can share tutorials on how to a) hide the sub-menus with CSS b) use a child theme to style the menu differently or 3) maybe activate a different mobile theme entirely.

Closing as worksforme since there isn't a convincingly better approach without redesigning it to look completely different.

#11 @lancewillett
9 years ago

In [21929]:

Twenty Twelve: update navigation script to check for missing button and menu children earlier; allows an empty menu to be set without showing the button. See #21678.

Note: See TracTickets for help on using tickets.