Titles fouling nicemenus in Safari

t42 - April 17, 2008 - 15:02
Project:Nice Menus
Version:6.x-1.3
Component:Browser Compat
Category:bug report
Priority:normal
Assigned:Todd Nienkerk
Status:needs work
Description

I've found a problem with dropdown style nicemenus with Safari where the expanded menus vanish apparently at random.

What's happening is that when you go over an "a" tag, Safari brings up the title as a little white box. It's possible to get the cursor over the tool tip itself, which seems to take the :hover off the menu item, so the whole menu collapses down...

No doubt those that know the guts of Drupal can fix this properly by removing the title attribute from the a tag.

On my site I've worked around this using the following javascript...

if (document.getElementById("nice-menu-1"))
{
myas = document.getElementById("nice-menu-1").getElementsByTagName("a");
for (i=0;i<myas.length;i++)
if (myas.item(i).title)
myas.item(i).title = null;
}

#1

add1sun - June 28, 2008 - 14:21
Status:active» won't fix

You can also do this by overriding the http://api.drupal.org/api/function/theme_menu_item_link/5 function to not print the title. This is out of scope for Nice menus though, so I'll won't fix it.

#2

WinterSky - July 16, 2008 - 22:22

I am using the Zen theme so simply added this to my sub-theme template.php file:

function zen_menu_item_link($item, $link_item) {
/* comment out the original which returns the 'title' value
return l($item['title'], $link_item['path'], !empty($item['description']) ? array('title' => $item['description']) : array(), isset($item['query']) ? $item['query'] : NULL);
*/

// disable the title value which triggers tooltips - tooltips breaks Safari drop-down nice menus
return l($item['title'], $link_item['path'], NULL);
}

NOTE: I have to completely disagree with the comment of add1sun above. This issue makes the Nice Menus module UNUSABLE in Safari (PC & Mac). As such it is not out of scope but completely in scope. It seems that a much better solution then mine above would be to turn off the title value only in nicemenu output (possibly as an option somewhere). That way the functionality is not lost site wide. I am a N00b though so it may be that Nice Menus cannot override the theme_menu_item_link() function within the module. Seems unlikely though given how I just overrode it for every page I generate. Research for another day.
- Orion

#3

WinterSky - July 16, 2008 - 23:38

My fix did not work for those who may have found this thread.
The issue is that other modules use the description to add other things (like the span tags on the tabs for editing page content).
Workaround - remove Description from menu items related to nice menus/nicemenus.
Working in 5.7.x - no titles being added to the menu links.
Cheers - Orion

#4

Todd Nienkerk - December 1, 2008 - 18:58
Title:Titles fouling nicemenus in Safari» Titles fouling nicemenus in Safari and Firefox 3

As reported in #326042: FF3: Use of title attribute causes flyout menus to disappear unexpectedly, this issue is also affecting Firefox 3. I am updating the title of this issue accordingly.

#5

Todd Nienkerk - December 1, 2008 - 19:16
Assigned to:Anonymous» Todd Nienkerk
Status:won't fix» active

Due to Nice Menus' use of theme_menu_item_link() to build the menu items, add1sun is right to say this bug is outside of the scope of this module.

However, I propose creating a new, module-specific theme function to handle this. This would allow non-technical users to install the theme without worrying about overriding theme functions. (Also, this allows themers to override theme_menu_item_link() for other purposes without fear of messing up Nice Menus' output.

I'll see if I can come up with a patch.

#6

Todd Nienkerk - December 1, 2008 - 19:37
Status:active» needs review

Here's a patch that adds two new functions: nice_menus_item_link() and theme_nice_menu_item_link(). These functions were largely copied from menu_item_link() and theme_menu_item_link(), respectively. The theme function does not include the title attribute, so simply adding this to the module and updating it will fix the tooltip bug.

PS. I also fixed a trivial formatting error in nice_menus_menu(). That's why you'll see it in the patch.

AttachmentSize
nice_menus_tooltip_bug.patch 2.89 KB

#7

samtherobot - December 18, 2008 - 19:32
Version:5.x-1.x-dev» 6.x-1.3

I'm wondering if there are any solutions for 6?

Here's mine at least. This way you don't have to modify any core of the nice menus module but you will have to copy a fairly large function into your template.php.

Copy the function theme_nice_menu_tree() from nice_menus.module into your template.php file and rename the function to phptemplate_nice_menu_tree().

Just below the line that loads the menu item ($item = menu_link_load($mlid);) add the following line

unset($item['localized_options']['attributes']['title']);

This hasn't been thoroughly tested but conceptually it works.

#8

Todd Nienkerk - December 22, 2008 - 20:13
Version:6.x-1.3» 5.x-1.x-dev

@samtherobot: While adding a function to template.php may fix the problem, it's usually not a good idea to require the user to edit that file just to enable a module. While I don't particularly like the idea of duplicating functionality from Drupal core just to tweak a couple of times -- as the patch I've provided does -- it doesn't require users to muck around with code.

I'm changing the version back to 5.x-1.x-dev because that's the version the patch fixes. It's important to note, of course, that a port to 6.x is needed. Perhaps when this patch is approved, we can change this issue to version 6.x with a status of "patch (to be ported)."

#9

add1sun - February 6, 2009 - 18:10
Version:5.x-1.x-dev» 6.x-2.x-dev
Status:needs review» needs work

So, my hesitation on this so far is that by adding our own version of a core function, if someone overrides theme_menu_item_link() they will expect it to work on all of their menu items but NM will ignore it. I'm going to try to spend some time working on NM issues over the next two weeks or so and I'd like to get this'un fixed one way or the other.

I also would like to make the fix against HEAD and backport, so I'm moving this to 6.x-2.x because I'd like a patch for that.

#10

wadley0 - June 24, 2009 - 22:19

So has this been fixed in the 6.x-2.x-dev?

Has anybody worked up a patch for the 6.x-1.3?

#11

alpirrie - July 10, 2009 - 09:53

I found the best way to get rid of the title attribute is to add the following code at the top of the nice_menus.js file.

$(document).ready(function(){
    // Get rid of all title attributes (they cause odd behaviour when the tooltips pop up)
    $('ul.nice-menu a[title]').each(function(){  
        $(this).removeAttr('title');
    });
});

It simply strips out all the 'title' attributes on the links within nice menus once the page has loaded.

If you don't want to add it here you can always add this same javascript to your theme.

Add:

scripts[] = myscript.js

to your themes .info file, and put the script above in myscript.js.

Hope this helps :-)

#12

echoz - August 19, 2009 - 06:17

Finally this bug has been fixed. I don't know if we can assume the next FF update will include it.
https://bugzilla.mozilla.org/show_bug.cgi?id=443178
Had numerous duplicates.

#13

Alex72RM - September 23, 2009 - 09:55
Title:Titles fouling nicemenus in Safari and Firefox 3» Titles fouling nicemenus in Safari
Version:6.x-2.x-dev» 6.x-1.3

#11 doesn't work for Safari.

So the issue is still valid only for this browser.

 
 

Drupal is a registered trademark of Dries Buytaert.