Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Not a request, but a solution :) I've tried lots of options, this one works. Really useful if you have a lot of content in tabs:
jQuery(window).load(function() {
jQuery("#accordion").accordion({
autoHeight: false,
collapsible: true,
heightStyle: "content",
animate: 400 // collapse will take 400ms
});
jQuery('#accordion h3').bind('click',function(){
var self = this;
setTimeout(function() {
theOffset = jQuery(self).offset();
jQuery('body,html').animate({ scrollTop: theOffset.top - 30 });
}, 410); // ensure the collapse animation is done
});
});
Comment | File | Size | Author |
---|---|---|---|
#4 | field_group-accordion-scroll-active-section-2637948-1.patch | 472 bytes | dbassendine |
Comments
Comment #2
juves CreditAttribution: juves commentedComment #3
dbassendine CreditAttribution: dbassendine commentedI think this is a valid issue to address - it's causing significant usability problems for us on a form that has many fields in each section. If you open a section, work through the form fields to the end, then click to open the next section - you end up at the bottom of the page. This is because the section above has collapsed, meaning your current page scroll position is now at the bottom.
Also see this problem described at http://stackoverflow.com/questions/3876433/jquery-ui-accordion-scrolling..., http://stackoverflow.com/questions/3621161/jquery-accordion-will-it-scro...
Here's a patch - I've used some of the code above, but adjusted to:
This is against 1.5 and tested on jQuery 1.7 (using jquery_update).
Comment #4
dbassendine CreditAttribution: dbassendine commentedPatch
Comment #5
smartparty CreditAttribution: smartparty commentedThis issue also applies to D8. The same patch can be adapted to suit within the accordion.js file within the formatters directory of the module. I'm using the adminimal admin toolbar so require an offset of - 80px.
i.e.
Comment #6
3CWebDev CreditAttribution: 3CWebDev commentedDrupal 8/9 patch here: https://www.drupal.org/project/field_group/issues/3284745#comment-14556534