Can anyone else reproduce this?

When managing form display, if you have several 'Tab' groups nested inside a "Tabs" widget (horizontal or vertical) - one tab is always stuck as the default, regardless of it's order among the other fields or if you've explicitly set it to "Closed" and another to "Open".

Then, if you remove that group, another unwanted tab becomes the default. The only workaround is to swap the fields between the tab you want and the tab you don't, and then rename both groups (so the descriptions no longer match the machine names).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

wturrell created an issue. See original summary.

weseze’s picture

Experiencing the exact same issue...

I've tracked it down to: (HorizontalTabs.php)

      foreach (Element::children($groups[$group_name]) as $child) {

which only seems to return 1 group, instead of all of them. So it always marks that group as default.

weseze’s picture

Priority: Normal » Major

Upping the prio because this is realy very annoying and there is no workaround.

jeroendegloire’s picture

This happens when I updated field group. I have deleted the group that this issue causes and created a new one. The new group hasn't this issuue

weseze’s picture

@jeroendegloire I tried recreating the group but the problem persists... I'm also running the latest version. The problem occurs both after updating an existing site or creating a new site from fresh up-to-date modules.

sleepingmonk’s picture

Status: Active » Needs review

When it loads `$groups` from `$form_state`, the data doesn’t have the values it’s looking for so default tab isn’t set correctly. I’m just ignoring $groups and pulling the data from somewhere it already exists in that function.

The proper way to handle it might be to go further back and see why the data isn't populated in $form_state.

This patch seems to solve our use case for Horizontal tabs. Vertical tabs doesn't seem to work the same way and working on Tabs.php didn't seem to have an effect.

This will take more work but here's a start for consideration.

sleepingmonk’s picture

weseze’s picture

Status: Needs review » Reviewed & tested by the community

Patch is working fine for us

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 7: wrong-default-tab-3066522-7.patch, failed testing. View results

Kasey_MK’s picture

Patch #7 works for us with a set of horizontal tabs nested within another set of horizontal tabs. Drupal 8.7.7, field_group 3.0.0-rc1. Thanks!

nils.destoop’s picture

The patch works for horizontal tabs on a normal node form. But it does not work:
- when the form is loaded as an inline entity form
- For vertical tabs

nils.destoop’s picture

Status: Needs work » Needs review
FileSize
3.91 KB

This version works for me with:
- horizontal tabs
- vertical tabs
- horizontal tabs in inline entity form
- vertical tabs in inline entity form

trafo’s picture

I'd say that you also need to sort element children:

Element::children($array, $sort = TRUE)

That helped me at least in case of horizontal tabs (HorizontalTabs.php):

foreach (Element::children($groups[$group_name], TRUE) as $child) {

For some for me unknown reason tab groups in tabs group are in order that you added them and not the order in which you ordered them in Manage form display.

  • zuuperman committed a04084e on 8.x-3.x
    Issue #3066522 by zuuperman, sleepingmonk: Wrong default tab on page...
nils.destoop’s picture

Status: Needs review » Fixed

Ok. I added the sort option + also removed the old code. This is committed to dev.

Status: Fixed » Closed (fixed)

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