As an admin, the block expansion and collapse works great. For my other users, expanding or collapsing blocks causes a page reload (a '#' is added to the end of the url). The blocks will expand/collapse but if the block is farther down the page, the user has to scroll back down after they expand/collapse. It would be better to have the block expand/collapse without reloading the page.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

aaronnaylor’s picture

I am wondering if there is any fix for this issue yet, or if one is coming soon. I love this module, but I'm not sure if I will be able to continue using it on my current project as it is. The re-scrolling issue makes the page really jumpy and it's pretty annoying... also, clicking on a link in the block causes block to collapse again (I have used CB in D6 and had no issue with it.) ... As admin, module works perfectly, when logged in as Authenticated or logged out is when issue shows up. Update please?

nathanjo’s picture

FileSize
465 bytes

For some reason, the js just return href="#".
Resolved this by modifying line#29 in collapsiblock.js:

.wrapInner('<a href="#' + id + '" role="link" />')

Attached patch.

nathanjo’s picture

Status: Active » Needs review
essbee’s picture

rather than this, which I find still makes the page jump around and thus doesnt provide as nice a UX. Could we instead just add
.wrapInner('<a href="#" role="link" onclick="return false;"/>')
This keeps the page position in the same place. The link isnt clickable anyway as this is hijacked by the collapsi event.

Thoughts?

Babymaggie’s picture

Just tried essbee's fix and I got to say it works great!

I was having the jumping screen problem so I tried the fix - Many thanks essbee

Also many thanks to the module creator - Great work!

gagarine’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Status: Needs review » Needs work

I guess we should use http://api.jquery.com/event.preventDefault/ instead. I don't want JS in html still if this html is dynamically created

dsdeiz’s picture

Hi, just wondering if this would work.

dsdeiz’s picture

Status: Needs work » Needs review
gagarine’s picture

I committed suggestion from #2.

I try to move the preventDefault right after the event is fired, I'm not sure it make a difference but anyway is more readable.

So you can try the dev when is packaged and report if it works for you.

gagarine’s picture

Category: support » bug
c4antonio’s picture

don't work with the last dev version, i have same problem, works fine only when an user is logged in, anonymous user when click on block title collapsed go on the top of page

xaa’s picture

hi,
Same issue with the 7.x-1.0. and the patch from #2 is working fine.

Regarding this issue with a mobile eye, this was a major issue.
The fix is really needed for the mobile version :) many thanks

m.schwarzenberg’s picture

#4 works wonderful - thanks essbee

GN’s picture

#4 works for me, too -
when trying, don't forget to clear cache (it may seem not working when block caching is on and your old block is still in the cache).
Thank you essbee!

GiorgosK’s picture

@gagarine at #9
you say committed solution from #2 ?
there is no dev or official release after your post date !!

but anyone of the solutions above should work

GiorgosK’s picture

Actually #2 still creates this problem #1568036: Browser jumps to top of page when block is opened
but #7 is behaving correctly and probably solves both problems

GiorgosK’s picture

Just to confuse the things a little more
on the same project at times #2 worked, #7 worked, but now reverted back to original .js file since patched versions were giving the same problem that were supposed to fix ??!!!

using omega 7.x 3.x subtheme if it makes any difference

jday’s picture

#4 works for me

vinmassaro’s picture

#4 was the only solution I found to work from this thread. I've rolled a patch against 7.x-1.x with this fix.

chefnelone’s picture

Has been this committed to the dev version? The patch is working.

vinmassaro’s picture

Status: Needs review » Reviewed & tested by the community

@chefnelone: Thanks for testing. Hasn't been much activity on this module, so it doesn't look like it. Moving to RTBC.

rCharles’s picture

Issue summary: View changes

I was getting a conflict between administration menu module and collapsiblock module when both installed (Omega 3, Bartik and other themes had "section.div" set for appearance settings). What would happen was, a # character was getting inserted into the URL (ie sitename.com/path#), and whenever a block was collapsed or expanded it would cause the page to jump to the top.

Solution:
https://drupal.org/files/use-preventDefault-1305364-7.patch

darvanen’s picture

For the record, the dev version available for download does not have #19 installed.

kopeboy’s picture

"Moving to RTBC" one year ago and still no patch in the dev version?!? wow

nevosa’s picture

#22 solved the issue for me on 7.x-1.0.
Thanks.

jenniferannwalsh’s picture

#22 patch also worked for me 7.x-1.0. Thanks rCharles!

brett1’s picture

Patch from #22 worked for me too (#7)
Thanks, this is a great module but the flicking up to the top of the page was effecting it.

kenheim’s picture

Patch from #22 fixed it for me. Seems like it should be ready for a commit.

fitzed’s picture

Patch from #22 worked for me too. Thank you!

darvanen’s picture

Rerolled #7/#22 patch on current dev release for test queue.

System Lord’s picture

#22 worked for me. I only noticed it on my android and now it's fixed. Thank you!

Btw..something is strange. Patch at #22 looks like this:

diff --git a/collapsiblock.js b/collapsiblock.js
index 27f3d40..96df1fb 100644
--- a/collapsiblock.js
+++ b/collapsiblock.js
@@ -76,6 +76,9 @@
             });
             e.preventDefault();
           });
+          $('a[role=link]', titleElt).click(function (e) {
+            e.preventDefault();
+          });
           // Leave active blocks uncollapsed. If the block is expanded, do nothing.
           if (stat ==  4 || (cookieData[id] == 0 || (stat == 3 && cookieData[id] == undefined)) && !$(this).find('a.active').size()) {
             // Allow block content to assign class 'collapsiblock-force-open' to it's content to force

Patch #30 looks like this:

diff --git a/collapsiblock.js b/collapsiblock.js
index 23ac4f5..29af8fe 100644
--- a/collapsiblock.js
+++ b/collapsiblock.js
@@ -76,6 +76,9 @@
               path: settings.basePath
             });
           });
+          $('a[role=link]', titleElt).click(function (e) {
+            e.preventDefault();
+          });
           // Leave active blocks uncollapsed. If the block is expanded, do nothing.
           if (stat ==  4 || (cookieData[id] == 0 || (stat == 3 && cookieData[id] == undefined)) && !$(this).find('a.active').size()) {
             // Allow block content to assign class 'collapsiblock-force-open' to it's content to force

If both are for DEV why are they different?

Also, Darvanen, unless i dont understand what "rerolled" means should that have updated the DEV date/version and been listed in the "view commits"? Is this thread the "test queue" ? Not griping. Just trying to understand.

darvanen’s picture

Hi @System Lord,

They're different because patch #22 was made for an old version of the dev branch. That is, the dev branch has had some changes made and committed since #22. This means when you try to use the patch it works, but it doesn't give the patch program exactly what it is expecting, and the automatic patch testing system doesn't like that.

Note that on https://www.drupal.org/node/332678 it states:

Patches can only be tested against the current version of the issue.

So I 'rerolled' it (basically just opened the dev branch at its current commit state and ran the patch) in order to make it test properly, and to make it slightly easier to commit for the maintainers.

Seems it hasn't been queued for testing yet, I'm not sure why.

System Lord’s picture

Understood, darvanen...thanks!

gagarine’s picture

Status: Reviewed & tested by the community » Fixed

commited

  • gagarine committed 2ae99e5 on 7.x-1.x authored by Darvanen
    Issue #1305364 by Darvanen, vinmassaro, dsdeiz, nathanjo: Expanding...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

semanthis’s picture

Problem still appears in 8.x-2.0.
e.preventDefault(); fixes the problem there es well.