Problem/Motivation

When using the horizontal tabs mode on entity forms, no tab is selected as "default" or "open" even though a child element might be marked as "open". This results in the core/drupal.form library always displaying the last tab open by default.

Proposed resolution

Determine the default tab by evaluating the "open" setting of child field groups. If none are marked as such, display the first tab as open/active. To do this we need to make sure all children have an HTML id set - this is already a requirement for other use cases, e.g. #2849759: Undefined index: id in template_preprocess_fieldset() notice.

Remaining tasks

Review, maybe add tests?

User interface changes

The tab displayed as open by default will be determined as outlined above, instead of always opening the last child.

API changes

Every child group will now always have an assigned HTML id - either the one configured or an automatic id generated from the group name.

Comments

ckaotik created an issue. See original summary.

ckaotik’s picture

Assigned: ckaotik » Unassigned
Status: Active » Needs review
StatusFileSize
new1.67 KB

Please review the attached patch.

kay_v’s picture

Version: 8.x-1.x-dev » 8.x-3.x-dev
Component: User interface » Code

This patch applies cleanly and resolves the stated issue when applied to field_group-8.x-3.x-dev

If priority setting makes a difference in this issue queue, consider changing it to major. The inability to change the default tab, and always having the last tab 'open', certainly invalidates one of the module's stated features.

I'm switching the issue version to the above since the current core version (Drupal 8.4) requires it per the module project page:

For Drupal 8.3 and higher, use the fieldgroup 8.3 branch. When you still use a drupal version lower then 8.3, use the fieldgroup 8.1 branch

geek-merlin’s picture

Status: Needs review » Reviewed & tested by the community

> This patch applies cleanly and resolves the stated issue when applied to field_group-8.x-3.x-dev

sime’s picture

StatusFileSize
new1.76 KB

Re-rolled against HEAD. Not manually reviewed, but seems more elegant than I expected it to be.

sime’s picture

  • zuuperman committed 0224e42 on 8.x-3.x
    Issue #2862079 by ckaotik, sime: Choose sensible default tab for...
nils.destoop’s picture

The patch was not working anymore in latest dev. I did some refactoring, and now it's ok.

nils.destoop’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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