Problem/Motivation
When a vertical tabs element contains multiple tabs with the 'Open' setting, the element sets the default tab to the last element with this attribute. However, it would make more sense to use the first one instead since this element appears first on the page.
This behavior was introduced in #3066522: Wrong default tab on page load.
Proposed resolution
Set the open tab to the first element with '#open' => TRUE.
Remaining tasks
- Write a patch
- Review
- Commit
User interface changes
None.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 3130339-9.patch | 1.13 KB | colan |
| #2 | 3130339-2.patch | 1.1 KB | idebr |
Issue fork field_group-3130339
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
idebr commentedAttached patch sets the open tab to the first element with
'#open' => TRUE.Comment #3
pdenooijer commentedNeeds a test to proof this patch works and to show the current behaviour is wrong.
Solution seems fine to me!
Comment #4
abelaguado commentedPatch #2 works nice.
Comment #5
maxilein commentedWorks on D10.2.1 perfectly even with very many tabs which have very many blocks.
Thanks!
Comment #6
davidmv97 commentedpatch #2 works fine in Drupal 10.2
Comment #7
sidgrafix commentedThis doesn't appear to work - at least for my situation!
On a content type under manage display using tabs group type horizontal with 3 tab(s) first 2 are set to closed, 3rd set to open, yet no matter what only the first tab loads opened.
Tried this patch as well as dev version that I believe was patched via MR for "#3066522: Wrong default tab on page load" and nothing seems to make it work correctly.
- so the only way to achieve the correct tab opening (as things stand), appears to be moving the tab you want open as the first tab that gets loaded (as first tab in tabs group) which is unfortunate.
Just to be clear before trying this patch or the dev version the first tab in a tab group loads open (doesn't matter if you set it to closed and have another tab in the group set to open - the first tab is always loaded opened.)
First trying this patch (same behavior, nothing changed)
Then trying the dev version (same behavior, nothing changed)
And there are no errors produced on page or in dblog.
For good measure incase others have this working on different setups my setup is currently using Drupal 10.2.3 on Apache 2.4.38 running PHP 8.1.13
Comment #8
colanThis is still a problem; updated version.
Marked #3206626: 2. tab is always active instead of the 1. one as a duplicate of this issue.
Comment #10
colanHere's a Composer patch, which aligns with the MR.
Comment #11
colanUpdating status because the change in the original patch is the same as this one; it's only the context that changed (even though
interdiffisn't returning anything). It looks like a good solution, and it works over here.#7: This is a separate issue. Please review the issue queue for that, or if you can't find it, open a new one.
Comment #12
anybodyThank you!! Merged.