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.
Sometimes the tabs randomly change position, not paying attention to the order allocated by the form.
Comment | File | Size | Author |
---|---|---|---|
#3 | tabweightissue.png | 3.69 KB | matt.nz |
Comments
Comment #1
nedjoHmm, possibly a bug introduced by the recent conversion in how we process tabs. Previously we explicitly assigned weights. I stripped out that code because it didn't seem to be needed any more, but possibly I was wrong....
Meantime you could explicitly assign #weight properties to your tabpage elements, but we should identify and fix this issue.
Comment #2
matt.nz CreditAttribution: matt.nz commentedAh, thanks, that works perfectly! I have a loop to generate the items and just added:
'#weight' => $tabcount++,
and it does exactly what it needs to.
Looks like the weights might be a necessity!
Comment #3
matt.nz CreditAttribution: matt.nz commentedHmm, apparently editing the weights doesn't completely fix the order the tabs want to take. Now the 'last' class is assigned to something that's not the last tab. For me, the second to last tab takes the class "last". Screenshot of tabs structure attached.
Comment #4
dwwFWIW, I'm seeing the same problem on a site I'm working on now using 6.x-1.2 of tabs. Manually setting the weight does the trick for me, too...
Comment #5
nedjoI haven't reproduced this issue. Could someone post the code that produces broken tabs?
I committed a fix to the error with first and last classes (moved to js rather than PHP, which ran before sorting by weight).
Comment #6
GiorgosKif no "#weight" is given then the order declaration is not kept
try using at least 4 tabs that should reveal the problem
Comment #7
GiorgosKusing tabs 1.3
Comment #8
matt.nz CreditAttribution: matt.nz commentedIt seems this is as simple to fix as re-adding the code that added the weights??
Comment #9
greg.harveyThis has just begun to happen for me after an update. No idea why. It worked fine on local dev server, but broke on live after update. Tab order is all over the place. Increasing the priority, since if the tabs module can't consistently order tabs created via the hook something is quite wrong! Testing now.
Comment #10
greg.harveyAdding weight seems to fix this - but something is wrong. Normally when you output an array without specifying weight the order is the order of the array. What I'm seeing is sometimes this is the case, but some other times (and it seems arbitrary) the array order is ignored and some seemingly completely random order is applied instead. There also doesn't seem to be anything in particular that triggers this random behaviour.
In short, it seems manually applying weight is a workaround, but not a fix.