Troubleshooting Bootstrap v4.4: Issues with Collapse Transition

I'm trying to add Bootstrap Collapse to my table data. However, when I click the button, the table data collapses, but without any transition effect. I've double-checked that I have included jQuery, used collapse (not collapse in), and added aria-hidden="true", data-toggle="collapse", data-target, and id properly. This issue is not related to the screen width.

For reference, here's a link to my code pen https://codepen.io/mezavanessa/pen/RwrYgqM where you can find my HTML & CSS code.

<section id="tableExpandedRows">
  <table class="table table-expanded expanded-row-bg-color">
    <thead>
      <tr>
        <th>heading one</th>
        <th>heading two</th>
        <th>heading three </th>
        <th>heading four</th>
        <th>heading five</th>
        <th>heading six</th>
        <th class="sr-only">Supplier ID</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>
          <button class="btn-collapse icon-caret-width" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="false" aria-controls="collapseOne">
            <img src="assets/img/icon-caret-down.svg" alt="" class="icon icon-caret-down">
          </button>
          209
        </td>
        <td>Gate Parts for Repair</td>
        <td>Magnolia Heritage Construction</td>
        <td>$32,456.92</td>
        <td>Jul 15, 2019</td>
        <td>Geralt Rivera </td>
        <td class="sr-only">2165465536484</td>
      </tr>

      <tr class="collapse" id="collapseOne" role="cell" aria-hidden="true">
        <td colspan="3" class="collapse-data">
          <div class="table-expanded-data">
            <h5>Supplier ID</h5>
            <p>608</p>
          </div>

          <div class="table-expanded-data">
            <h5>Ship To</h5>
            <address>
              Fairview Gardens<br>
              567 Fairview Circle<br>
              Columbia, SC 29073
            </address>
          </div>

          <div class="table-expanded-data">
            <h5>Ship To Code</h5>
            <p>907</p>
          </div>
        </td>
      </tr>
</section>

    .table {
      background: $off-white;
    
      border: none;
    
      thead {
        background-color: rgba(5, 116, 176, 0.2);
        border: 1px solid rgba(5, 116, 176, 0.1);
    
        th {
          border: none;
        }
      }
    
      th {
        font-size: 0.875em;
      }
    
      th,
      td {
        padding: 1rem;
      }
    
      tr:first-child {
        td {
          border-top: none;
        }
      }
    }
    
    th {
      border: none;
    }
    
    td {
      border-color: rgba(52, 77, 91, 0.36);
    }
    
    .table-expanded-open tr:nth-child() {
      background-color: $table-accent-bg;
    }
    
    // Expanded Rows//
    
    .btn-collapse .icon-caret-down {
      transition: transform 0.2s ease-out;
    }
    
    .btn-collapse[aria-expanded="true"] .icon-caret-down {
      transform: rotate(0.5turn);
    }
    
    .table-expanded-data {
      display: inline-block;
      padding: 0 1em;
      vertical-align: top;
    }

Answer №1

This situation is a common issue when attempting to collapse tables. One workaround is to insert a DIV inside the TR and collapse that instead. Here's the updated codepen link: https://codepen.io/feardarkness/pen/ExPeMry

<section id="tableExpandedRows">
  <h2>Expanded Rows</h2>
  <p>
    Users can engage with a table featuring Expanded Rows to reveal additional content by clicking on the Down-Caret icon for expanding a row vertically. It's crucial to have hidden elements like those marked with the sr-only class to guarantee all content is accessible to screen readers.
  </p>

  <table class="table table-expanded expanded-row-bg-color">
    <thead>
      <tr>
        <th>heading one</th>
        <th>heading two</th>
        <th>heading three </th>
        <th>heading four</th>
        <th>heading five</th>
        <th>heading six</th>
        <th class="sr-only">Supplier ID</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>
          <button class="btn-collapse icon-caret-width" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="false" aria-controls="collapseOne">
            <img src="assets/img/icon-caret-down.svg" alt="" class="icon icon-caret-down">
          </button>
          209
        </td>
        <td>Gate Parts for Repair</td>
        <td>Magnolia Heritage Construction</td>
        <td>$32,456.92</td>
        <td>Jul 15, 2019</td>
        <td>Geralt Rivera </td>
        <td class="sr-only">2165465536484</td>
      </tr>

      <tr>
        <td colspan="6" class="collapse-data">
          <div class="collapse" id="collapseOne" role="cell" aria-hidden="true">
            <div class="table-expanded-data">
              <h5>Supplier ID</h5>
              <p>608</p>
            </div>

            <div class="table-expanded-data">
              <h5>Ship To</h5>
              <address>
                Fairview Gardens<br>
                567 Fairview Circle<br>
                Columbia, SC 29073
              </address>
            </div>

            <div class="table-expanded-data">
              <h5>Ship To Code</h5>
              <p>907</p>
            </div>
          </div>

        </td>
      </tr>
</section>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Acquire Table Element Using Javascript

I have a HTML table that contains information such as names, addresses, and phone numbers. Within each row of the table, there is a link that can be clicked to open a popover. When a popover is opened, I want to save the name from that particular row. The ...

What is causing the issue with transmitting the server datetime to my local jQuery script?

I am facing an issue with my timeoftheserver.php page setup. The PHP code is quite simple: <?php echo date('D, d M y H:i:s'); ?> Similarly, the script on my local machine is also straightforward: var today; try { today = new Date($. ...

ArrayObservable causing issue with Knockout's checked binding functionality

I am encountering an issue with my observableArray that is bound to a pair of checkboxes. Despite following the documentation, the array is not changing as expected. Special note: If your parameter resolves to an array, KnockoutJS will check the element i ...

Enhance the appearance of your Table footer with a personalized touch

I have two different Text components that I am working with. You can view some examples of these components here. Here is the scenario: Text1 is located within a form (labeled as text) Text2 is situated in the footer area of a table In each text, I hav ...

The getJSON API functions properly on a local machine but encounters issues when deployed on a

I have a vision to create a web application that can display the weather of any city based on user input. I've divided my project into three files - index.html for collecting user input, index2.html for retrieving and displaying the data, and a CSS fi ...

The jquery datetimepicker function cannot be located or is not functioning as intended

<link href="css/bootstrap-datetimepicker.min.css" rel="stylesheet" /> <script src="Js/bootstrap-datetimepicker.min.js"></script> <script src="Js/bootstrap-datetimepicker.he.js"></script> ...

Unexpected appearance of blank space to the right of my parallax design

Ever since a forced reboot, my parallax scrolling page has been experiencing issues. A strange whitespace seems to be throwing off the sections, only appearing every other section - one is fine, the next is offset, and so on. I've carefully gone thro ...

I'm looking to replicate the testimonial slider from the link provided. How can I achieve this?

I'm looking to replicate the testimonial section layout seen on Kanbanize, which features both vertical and horizontal sliders. I'm unsure of how to link the two sliders so they move in sync. I typically use Swiper for carousel/slider functionali ...

The toggle button is having issues functioning properly within a While loop

Is there a way to enable slideToggle for all my queries? Currently, it is only working on the first query. Any suggestions on how to resolve this issue? JS code $(document).ready(function(){ $("#SendCopy").click(function(){ $("#users").slideToggle("s ...

JavaScript file slicing leads to generating an empty blob

I am currently working on a web-based chunked file uploader. The file is opened using the <input type="file" id="fileSelector" /> element, and the following simplified code snippet is used: $('#fileSelector').on('change', functio ...

Having trouble with jQuery focus not functioning properly?

I've been attempting to implement a focus function on a specific input in order to display a div with the class name .search_by_name when focused. However, I'm encountering issues and would appreciate it if someone could review my code to identif ...

Expand the div width to the specified measurement horizontally

Is there a way to horizontally collapse a div (container) to a specific width that I can adjust, effectively hiding its content? The collapse effect should move towards the left. <div id="container"> <button type="button" id="myButton"> ...

Can the multiline option on a textarea be turned off?

Although I can utilize the standard HTML text box, I specifically require a text area for certain reasons. Therefore, I am curious if there is a way to deactivate the multiline option of the textarea? ...

What is the best way to display an image during the waiting period for an AJAX response?

Can anyone provide some guidance? I'm attempting to use a loading gif while waiting for a response from an ajax request. Unfortunately, the gif is not being displayed when sending an email. I've searched through multiple pages on different platf ...

Adjusting the screen width to activate a responsive nav bar with a centered title

I'm facing an issue with the alignment of the heading within a navigation bar, causing the links to wrap before the collapse of the nav-bar occurs - https://i.sstatic.net/bKyPM.png I am trying to make the links collapse earlier than they currently d ...

steps for repairing a scoreboard

Is there a way to make my scoreboard increase by +1 point instead of +10? In my JavaScript code, I used intervals as it was the only solution that worked: let scoreInterval = setInterval(updateScore); let score = 0; function updateScore() { var poin ...

Creating an automated HTML tag for a form input

https://i.sstatic.net/ZBDk2.png Is there a plugin to create form inputs like the one shown above? How can I add this feature to my own website? I would like for every user input to automatically add the < br > tag. ...

The styling of HTML elements is ineffective when using scoped styles

I'm facing an issue where my element styling doesn't seem to work when using the scoped attribute. Upon inspecting the element, it appears that the styling is not being applied when using scoped. The reason I need to use scoped is because I want ...

The function Rotate() does not exist

Within my project, I have set up a canvas where I am able to: Load an image onto the canvas Resize the uploaded image Currently, I am working on implementing a rotate function that allows me to rotate the loaded image within the canvas by holding down th ...

Show variously colored information for each selection from the dropdown using Angular Material

I am trying to change the color of displayed content based on user selection in an Angular application. Specifically, when a user chooses an option from a dropdown list, I want the displayed text to reflect their choice by changing colors. For example, i ...