I'm the co-maintainer of the Menu MiniPanels module. We're working on 7.x-2.x branch of that module to abandon qTip (#2215425: Menu Minipanels V2 without qtip), and integrate with Superfish. As part of our testing we've discovered that everything is working nicely, our mini-panels are being shown inside superfish menus, ajax reloading of views inside mini-panels works great.
However on mobile / small screens with the smallscreen accordion menu configuration enabled, views ajax links are completely broken, they are treated as regular links and open the page.
My hunch is that this has something to do with the entire DOM structure of the sf-menu being cloned to build the accordion. I wonder what was the motivation for cloning the DOM instead of changing out the necessary classes on the existing structure?
Might it be possible to use the same DOM menu structure for both accordion and full menu? If so, I might start looking into a solution for this. This is truly sad, because I was hoping the integration would be nearly seamless :(
Comment | File | Size | Author |
---|---|---|---|
#19 | superfish-smallscreen_accordion_breaks_ajax-2225001-19.patch | 611 bytes | lklimek |
#18 | sfsmallscreen.zip | 4.52 KB | mehrpadin |
#15 | menu_minipanels-unique-id-for-superfish-2225001.patch | 929 bytes | jwilson3 |
#7 | superfish-smallscreen-accordion-ajax-2225001.patch | 677 bytes | jwilson3 |
Comments
Comment #1
jwilson3Comment #2
jwilson3Comment #3
jwilson3Comment #4
jwilson3acrollet gave me a good idea to try to run Drupal.behaviors() after adding the new Dom elements, which might solve this issue. I'll look into it and see if that does it.
Comment #5
mehrpadin CreditAttribution: mehrpadin commentedHey there,
Great, I'll update the plugin soon, if Drupal Behaviors didn't fix the problem setup an example and put it online so I can check, thanks! also, regarding these parts:
It was basically not possible, because not only it had to be able to create
<select>
elements the accordion style also needed a wholly different structure to work as expected, things like the button that controls the visibility of the whole accordion, the expand & collapse links of each parent and so on and so forth, in addition to all this, in many many cases dropdowns made for desktop versions have stuff that is impossible to fit in either a<select>
or an accordion, so there had to be a way to sanitize the input anyway, on the other hand even if there was a way to use the same object for all the three it could be very much resource-consuming to alter the object and revert and so on (revert as in for example when switching from portrait to landscape on a tablet) so all in all it was not possible nor efficient.Yet technically speaking yes it is possible to use the same object for an
accordion
and a full menu - but not a<select>
indeed - however only and only if we somehow can make sure the object does not and will not contain anything that gets in along the way and breaks either the accordion structure or behavior or both and so on and so forth.Haven't tried Mini Panels so pardon me if it sounds silly: isn't it better to not to include "columns" in the accordion menu at all? sfSmallscreen uses a class (
.sf-smallscreen-remove
) to figure out what should be removed while cloning (yes no documentation yet so no one knows this, will update the whole documentation soon) so if you add the class to all the elements in a MiniPanel except for<ul>
,<li>
, and<a>
, and even<span>
I guess you can then use the word seamless with a semicolon and the other kind of parentheses :DComment #6
jwilson3I feel you about needing to clean up the UL structures for conversion to select lists. However, with the advent of responsive layouts, I felt that stacking of columns and having a mega menu that requires scrolling down the page is not an invalid method for navigation, on the contrary, it is one that works fairly well with the accordion functionality.
Aside from what you've stated above, why couldn't we just add/remove the sf-accordion class from the ul, and do the rest (eg hiding of elements, changing / stacking layouts) in CSS? This doesn't seem that it would be too resource intensive, but of course, I could be missing something.
Comment #7
jwilson3Unfortunately, Drupal.attachBehaviors did not fix the problem. There is a fundamental issue with using javascript
clone()
on a view that has ajax enabled, because of the DOM ID used by views, created based on an md5 hash. Clicking the ajax pager of the cloned object still tries to update the view in the original menu, not the one in the cloned accordion menu.Also, fwiw, switching to javascript
clone(true)
doesn't solve this problem either, as it suffers from exactly the same issue -- the original DOM object is updated, not the clone.I've setup a testing site at https://dev-responsive-minipanels.gotpantheon.com, with the following modules:
I've attached the patch of what I've currently written, and is currently being used on https://dev-responsive-minipanels.gotpantheon.com.
Comment #8
jwilson3So its clear, here is how to see the error:
Comment #9
jwilson3I ran with the idea of not cloning the menus, and have forked the Superfish-For-Drupal on github, to see what would happen.
https://github.com/jameswilson/Superfish-for-Drupal/commit/60c2e89e5112d...
Long story short, i got it partially working, and ajax views behave properly (yay!) however (ohnoes!) a couple other issues have popped up as a result of not cloning:
<li>
elements ( except for where that class is used to toggle visibility of the entire menu on the<ul>
).<li>
elements in a data object, so that I can swap them out, similar to what I'm doing on the<ul>
.Comment #10
mehrpadin CreditAttribution: mehrpadin commentedJames,
Thanks for the demo, and all these :) I'll be back soon with some thoughts, busy cleaning up the issue queue at the moment!
Comment #11
jwilson3Thanks for having a look!
Just to be clear the changes i was working on in #9 are NOT what is being used on the demo site, which still contains the clean original github master branch, and the module patch on #7.
Comment #12
mehrpadin CreditAttribution: mehrpadin commentedYou're welcome, thank you, I've found a solution! need to do some profiling then testing with a few other modules etc before sharing :) there are two things also that we need, at least only when SF module exists: a) the main
<ul>
(the one that gets amenu-minipanel-panel
class) to have an ID, needless to say it has to be unique, I've no idea how one should be generated, perhaps anmd5
of panel name plus block ID? just an idea b) the very same element to also have asf-smallscreen-move
class, well from which you can guess what the solution is!Comment #13
jwilson3Easy, we can use the mini_panel's machine name and run it through
drupal_html_id
in our module (patch in next comment).Actually, can you spell it out? what does this do? I'm not familiar with what this class does, and am tied up in other things right now.
You can implement a preprocess function in superfish module to add the needed class like this:
Comment #14
mehrpadin CreditAttribution: mehrpadin commentedGreat, that class would help the sfSmallscreen plugin find out which element(s) must be moved to the small-screen version rather than cloned, moved there and then returned also and so on.
Comment #15
jwilson3Patch for comment #13 item A to add unique ID (Note this is a patch for menu_minipanels module, not superfish). I updated the comment #13 with some more info, please re-read if you already have.
Comment #16
jwilson3Can you let me know how this goes?
I can expedite getting this patch into menu minipanels 7.x-2.x-dev asap, it almost makes sense to do anyway.
Comment #17
jwilson3Comment #18
mehrpadin CreditAttribution: mehrpadin commentedJames,
Try the attached, bear in mind much of this will be definitely changed, also regarding your update, the class should be added through the Menu MiniPanel not SF.
Comment #19
lklimek CreditAttribution: lklimek at Software Inn commentedI've encountered a similar issue. It was caused by invalid order of behaviors. Can be simply fixed with the help of behavior_weights module; please see attached patch (don't forget to download and enable behavior_weights).
Comment #20
fox_01 CreditAttribution: fox_01 commented#19 works without updateing sfsmallscreen..js from #18
Comment #21
jwilson3Not sure we should be adding a new dependency to the module just to solve this sufficiently "edge" case. Damien?
What if we add the weight part of the patch in #19, and then add a note to Readme and Project in "Known Issues" section (or the like) referencing this issue and how to resolve it using behavior weights module?
Comment #22
fox_01 CreditAttribution: fox_01 commentedi think this should do the thing if you add the weight to the module and describe when the dependency is needed and that this has to be installed manually.
Comment #23
lklimek CreditAttribution: lklimek at Software Inn commentedIn my opinion, this is not a matter of "edge" case. Current implementation breaks many jQuery-based mechanisms, not only Ajax.
Core problem here is that Superfish copies some parts of DOM. If called too late (that is, if not called as the first behavior on the page), it copies code already processed by other behaviors (and having, for example, "ajax-processed" class set) but it DOES NOT copy attached jQuery handlers (like click() handler).
Well-designed third-party JS code shall use .once() or similar mechanism to ensure it doesn't process a given DOM node twice. Unfortunately, as the DOM has been copied with "-processed" class already set, the copy will be skipped and not processed at all - and handlers will never be attached.
Bad news is that this is "not deterministic", as it does depend on order of behavior execution, which can be different in different setups. So it's likely that module author will do some testing and assume that everything works well, while users might encounter hard-to-debug issues.
Comment #24
jwilson3Thanks for #23, but I don't understand your position entirely. In your opinion, is this something that would demand the extra module dependency? or could we try this as a partial patch + documentation issue as I suggest?
Comment #25
lklimek CreditAttribution: lklimek at Software Inn commentedIn my opinion, the issue should be fixed in code and work out-of-box. If we go with my patch, we should add the dependency (it's only 2kB of JS code).
In current state, it is hard to spot during testing & debug potential issues. And people don't read the docs ;-).
Comment #27
mehrpadin CreditAttribution: mehrpadin commentedHey there,
Thanks, don't we need this for D8? just wondering.
Comment #28
ivnish CreditAttribution: ivnish commented