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.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | field_group-default_tab-2862079-5.patch | 1.76 KB | sime |
| #2 | field_group-default_tab-2862079-2.patch | 1.67 KB | ckaotik |
Comments
Comment #2
ckaotikPlease review the attached patch.
Comment #3
kay_v commentedThis 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:
Comment #4
geek-merlin> This patch applies cleanly and resolves the stated issue when applied to field_group-8.x-3.x-dev
Comment #5
simeRe-rolled against HEAD. Not manually reviewed, but seems more elegant than I expected it to be.
Comment #6
simeComment #8
nils.destoop commentedThe patch was not working anymore in latest dev. I did some refactoring, and now it's ok.
Comment #9
nils.destoop commented