When there is a child collapsible fieldset within a parent collapsible fieldset, and you expand the child fieldset, the Drupal.collapseScrollIntoView() JavaScript function fires twice: once for the child, and then again for the parent. This results in the page ultimately being scrolled to the top of the parent.

To reproduce, create a simple form with a parent and child collapsible fieldset:


  $form['parent'] = array(
    '#type' => 'fieldset',
    '#title' => t('Parent fieldset'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );

  $form['parent']['child'] = array(
    '#type' => 'fieldset',
    '#title' => t('Child fieldset'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );

It isn't easy to see the issue with such a small form, so to illustrate, also put a console.log(node); at the top of Drupal.collapseScrollIntoView() in bootstrap/js/misc/_collapse.js.

Clicking on the "Child fieldset" to expand it results in two logs in the console:

<fieldset id="edit-child" class="collapsible panel panel-… map-collapse-processed">
<fieldset id="edit-parent" class="collapsible panel panel-… map-collapse-processed">
CommentFileSizeAuthor
#2 3155198-2.patch456 bytesm.stenta

Comments

m.stenta created an issue. See original summary.

m.stenta’s picture

StatusFileSize
new456 bytes

For my immediate needs, I've decided to simply disable this automatic scrolling behavior.

Attached is a patch that removes the Drupal.collapseScrollIntoView($fieldset.get(0)); line from _collapse.js, for use in my Drush Makefile. Not for review! Just a temporary hack fix.

Happy to help with a proper fix! But I'm not entirely sure what's causing it to fire twice. Something with the jQuery selectors used? The collapse logic is a bit hard to wrap my head around.

markhalliwell’s picture

Status: Active » Closed (won't fix)

Considering that D7 is, more or less, on LTS... I doubt this issue will go anywhere; so closing.