Horizontal/vertical tabs set default tab to last item with #open = TRUE

Created on 23 April 2020, over 4 years ago
Updated 29 February 2024, 11 months ago

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.

πŸ› Bug report
Status

Needs work

Version

3.0

Component

Code

Created by

πŸ‡³πŸ‡±Netherlands idebr

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¦πŸ‡ΉAustria maxilein

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

  • patch #2 works fine in Drupal 10.2

  • πŸ‡ΊπŸ‡ΈUnited States sidgrafix

    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

Production build 0.71.5 2024