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;
}

Comments

add1sun’s picture

Status: Active » Closed (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.

WinterSky’s picture

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

WinterSky’s picture

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

todd nienkerk’s picture

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.

todd nienkerk’s picture

Assigned: Unassigned » todd nienkerk
Status: Closed (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.

todd nienkerk’s picture

Status: Active » Needs review
StatusFileSize
new2.89 KB

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.

samtherobot’s picture

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.

todd nienkerk’s picture

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)."

add1sun’s picture

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.

wadley0’s picture

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

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

alpirrie’s picture

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 :-)

echoz’s picture

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.

alex72rm’s picture

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.

ressa’s picture

Thanks alpirrie, it works beautifully (post #11), I tested in Firefox and Opera.
To others: remember to flush the Theme registry for the script to take effect.
EDIT: I did not test it in Safari.

alex72rm’s picture

Hi,

which version of Safari have you?

I've flushed theme registry. The problem arises only with Safari.

ressa’s picture

I didn't test it in Safari, only Firefox and Opera. I'll add that to my former comment.

traviscarden’s picture

StatusFileSize
new605 bytes

If anybody would like #11 in the form of a module, here it is. Thanks for the code, alpirrie; it works great!

alpirrie’s picture

Glad the JS has worked for some people. And thanks TravisCarden for the module!

BTW, the #11 change to nice_menus.js appears to work okay in my version of Safari (4.0.4 (5531.21.10) on a MacBook 10.5.8). Is the javascript not working in the problem Safaris (i.e. titles not being stripped)? Or is there another problem?

add1sun’s picture

Version: 6.x-1.3 » 6.x-2.x-dev

The only problem with using a JS fix for this is that the idea is that the menus will work fine when falling back to CSS-only. On the other hand, I dare say most folks will use the JS in V2, even though it is optional, so maybe even though this is a half-fix, it is better than nothing and will probably work for the 80% use case. This needs to be an actual patch though, instead of a tarballed version. Also, needs to be against 6.x-2.x-dev.

add1sun’s picture

Assigned: todd nienkerk » Unassigned
Status: Needs work » Postponed (maintainer needs more info)

In Safari 5 I am not getting this problem anymore. Can anyone confirm if this is still a problem in modern browsers? If not, I'll close this issue out in a few weeks.

foxydot’s picture

I think this is the issue I'm seeing in Chrome and Safari right now. On Mac10.6.4 chrome 9.0.572.1 dev, Safari Version 5.0.2 (6533.18.5). It looks like some of the menu items simply aren't being returned...it almost looks like a php problem, because the items aren't in the HTML at all, so perhaps it is some other issue, but the cut-off seems to be happening at a title tag.
Nevermind. I had a brain fart. Not a nicemenu issue.

add1sun’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)