Problem/Motivation
When a block is set to be collapsed by default, it is not collapsed on a page if the content of the block has a link to the page you are viewing.
Eg. A block with the user menu is created and set to collapsed by default. On the front page the block works as expected, however on the user page (there is a link to the user page in the user menu and therefore in the block) the block is expanded by default and the menu link is styled as an active link.
Proposed resolution
This may be a feature on purpose in which case it would be nice to have an option to disable this.
Otherwise, we need to find a way to stop this from happening.
Remaining tasks
- TBC
Comment | File | Size | Author |
---|---|---|---|
#6 | 2447245-3.patch | 3.46 KB | sonvir249 |
Comments
Comment #1
yanniboi CreditAttribution: yanniboi commentedI believe that these issues are probably related to the one I have described.
Comment #2
yanniboi CreditAttribution: yanniboi at CTI Digital commentedSo looking at the code in collapsiblock.js it looks like this is desired behaviour. But I definately do not want that to be forced. The attached patch removes it, however I think an option on the block configuration page might be nice allowing users to choose whether the block is expanded on active pages.
Comment #3
MariskaTh CreditAttribution: MariskaTh commentedHello,
Thank you for this module. It really helped me out. I'm not sure my problem is related to the current issue, but just in case I post this in here.
I have also set a menu in a block and set that to 'Collapsed by default'. The block seems to work fine. The only problem is that it doesn't collapse after a page refresh. So the block is collapsed, I expand it and click on a menu item. The website goes to the other page and then the block is still expanded. I can collapse it by clicking it, but I would expect that a page refresh would result in that the blocks that are set to 'Collapsed by default' would automatically collapse again after a page refresh.
Am I right or is what I see the expected behaviour?
Thanks,
Mariska.
Comment #4
darvanenInitial discussion of this issue and potential remediation is in #1953062: Collapsed by default not compatible with sortable table.
Comment #5
darvanenThe patch in #2 is not backwards-compatible, it removes something that may be seen as a desired feature by some.
Comment #6
sonvir249 CreditAttribution: sonvir249 as a volunteer and at QED42 commentedHi @Darvanen,
$(this).find('a.active').size()
search in whole page that is why we can not add as a per-block setting.Comment #7
darvanen$(this)
refers to the block defined in line 16:.find()
only searches descendants (children).So it can be done as a per-block setting.
This is not a functional change, it's just removing an unused variable, which is a good thing to do, but that's what I was suggesting we should leave out of this.
This is coming along nicely, great work :)
It's probably a good idea to practice giving your patches the recommended name (put a short description in front of the issue code and comment number).
Comment #8
darvanenOh and don't forget to add the new setting to the uninstall hook.
Comment #10
darvanenThanks @sonvir249 and @yanniboi.
I added an uninstall hook and tried to make the JS a bit more readable, but you are the credits for this commit.
Comment #11
darvanenOh and I did test this with menu blocks, the language switcher block from core, and sortable tables - all worked.