Bootstrap v3: First tab content does not initially display

Created on 23 January 2023, almost 2 years ago
Updated 27 January 2023, almost 2 years ago

Problem/Motivation

Changes introduced in #3250429: The existing template implementation seems to bypass some core field template functionality β†’ inadvertently removed the in class that Bootstrap 3 needs for toggling tabs. As a result, the tab content does not initially display when first loaded.

Steps to reproduce

1. Use this module with Bootstrap 3 (the Drupal theme "Bootstrap" can facilitate this).
2. Create a field of type "Horizontal Tab" and populate content in multiple tabs.
3. When rendered, the tab content does not display until you click on a tab. The content of the first tab should initially display.

Proposed resolution

diff --git a/src/Plugin/Field/FieldFormatter/BootstrapHorizontalTabs.php b/src/Plugin/Field/FieldFormatter/BootstrapHorizontalTabs.php
index 6b24fa2..6db7014 100644
--- a/src/Plugin/Field/FieldFormatter/BootstrapHorizontalTabs.php
+++ b/src/Plugin/Field/FieldFormatter/BootstrapHorizontalTabs.php
@@ -189,6 +189,7 @@ class BootstrapHorizontalTabs extends FormatterBase {
         $elements[$delta]['#header_attributes']->setAttribute('aria-selected', 'true');
         $elements[$delta]['#body_attributes']->addClass('active');
         $elements[$delta]['#body_attributes']->addClass('show');
+        $elements[$delta]['#body_attributes']->addClass('in');
       }
     }
πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mark_fullmer Tucson

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

Comments & Activities

Production build 0.71.5 2024