superfish icon indicating copy to clipboard operation
superfish copied to clipboard

Menus all open if hidden by a media query on superfish.init()

Open dholth opened this issue 10 years ago • 8 comments

If superfish.init() is called when the superfish menu is hidden (as by a media query setting display: none) then the hide() method opens all of the menus. When the browser grows to a size that is intended to show the superfish menu then all of the dropdowns are open and shown.

I noticed that the hide method calls $ul.show() and then $ul.stop(true, true) to attempt to instantly re-hide the menu. I'm not clear on why it does this, but it looks like something about the $ul.stop() call does not work when the menu is display: none.

dholth avatar Mar 18 '14 13:03 dholth

Interesting find. I'll keep it in mind when working on the next release. Thanks.

joeldbirch avatar Apr 04 '14 02:04 joeldbirch

I did solve this. I set the .style property of the offending div to display: block, call superfish.init(), and immediately hide it again. There is no flash because javascript doesn't return to the browser during this operation. Sometimes it causes an error message on IE8, which we deal with by returning if .style is null or undefined.

dholth avatar Apr 04 '14 12:04 dholth

I believe that if you comment out line 141 in superfish.js, namely this: $ul.show();

... it will work fine

raduGaspar avatar Apr 23 '14 13:04 raduGaspar

I've seen this issue when there is an iframe on the page. The full menu tree is expanded when you first hover over a menu item, the fix suggested by raduGaspar seems to work.

robgeorgeuk avatar Apr 25 '14 08:04 robgeorgeuk

I'm just wary that the fix suggested by @raduGaspar may cause other bugs. I remember I added that code for a reason.

joeldbirch avatar May 10 '16 05:05 joeldbirch

When the browser grows to a size that is intended to show the superfish menu then all of the dropdowns are open and shown.

When exactly does a browser "grow"? Is this a realistic scenario (e.g. happens when changing device orientation on iPad)? If not, seems like an implementation concern to me.

FYI - https://github.com/joeldbirch/superfish/issues/158#issuecomment-232315795

ghost avatar Mar 20 '17 07:03 ghost

When you resize a desktop browser. It could happen when you rotate your ipad, sure.

dholth avatar Mar 20 '17 13:03 dholth

We are facing this issue in IE11 only and is there any plans for releasing official fix?

last-Programmer avatar Sep 12 '19 16:09 last-Programmer