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

  1. Write a patch
  2. Review
  3. Commit

User interface changes

None.

API changes

None.

Data model changes

None.

CommentFileSizeAuthor
#10 3130339-9.patch1.13 KBcolan
#2 3130339-2.patch1.1 KBidebr
Command icon 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

idebr created an issue. See original summary.

idebr’s picture

Status: Active » Needs review
StatusFileSize
new1.1 KB

Attached patch sets the open tab to the first element with '#open' => TRUE.

pdenooijer’s picture

Status: Needs review » Needs work

Needs a test to proof this patch works and to show the current behaviour is wrong.

Solution seems fine to me!

abelaguado’s picture

Patch #2 works nice.

maxilein’s picture

Works on D10.2.1 perfectly even with very many tabs which have very many blocks.
Thanks!

davidmv97’s picture

patch #2 works fine in Drupal 10.2

sidgrafix’s picture

This 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

colan’s picture

Version: 8.x-3.x-dev » 4.1.0-alpha1

This is still a problem; updated version.

Marked #3206626: 2. tab is always active instead of the 1. one as a duplicate of this issue.

colan’s picture

Status: Needs work » Needs review
StatusFileSize
new1.13 KB

Here's a Composer patch, which aligns with the MR.

colan’s picture

Status: Needs review » Reviewed & tested by the community

Updating status because the change in the original patch is the same as this one; it's only the context that changed (even though interdiff isn'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.

anybody’s picture

Status: Reviewed & tested by the community » Fixed

Thank you!! Merged.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • anybody committed 874c6deb on 4.x authored by colan
    Issue #3130339: Set the open tab to the first element with '#open' =>...

Status: Fixed » Closed (fixed)

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