The Tab control's ACTIVE selector is currently identifying active child elements within the tab-pane, causing interruptions in the tab navigation process

While using bootstrap v-4, I encountered an issue when utilizing bootstrap-select version 13 within a tabbed navigation. Upon investigation, I discovered that the active page link in the bootstrap-select was being updated instead of the tab navigation.

You can view a JSFiddle demonstration with a small tabbed navigation featuring pagination (which also has an active class in child elements) within each tab.

JSFiddle: https://jsfiddle.net/nrda8vjq/7/

<ul class="nav nav-tabs" id="myTab" role="tablist">
    <li class="nav-item">
        <a class="nav-link active" data-toggle="tab" href="#home" role="tab">Home</a>
    </li>
    <a class="nav-link" data-toggle="tab" href="#profile" role="tab">Profile</a>
    <li class="nav-item">
        <a class="nav-link" data-toggle="tab" href="#messages" role="tab">Messages</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" data-toggle="tab" href="#settings" role="tab">Settings</a>
    </li>
</ul>

<!-- Tab panes -->
<div class="tab-content">
    <div class="tab-pane active" id="home" role="tabpanel">
        <h3>Home</h3>
        <nav aria-label="...">
            <ul class="pagination">
                <li class="page-item disabled">
                    <a class="page-link" href="#" tabindex="-1">Previous</a>
                </li>
                <li class="page-item"><a class="page-link" href="#">1</a></li>
                <li class="page-item active">
                    <a class="page-link" href="#">2 <span class="sr-only">(current)</span></a>
                </li>
                <li class="page-item"><a class="page-link" href="#">3</a></li>
                <li class="page-item">
                    <a class="page-link" href="#">Next</a>
                </li>
            </ul>
        </nav>
    </div>
    <div class="tab-pane" id="profile" role="tabpanel">
        <h3>Profile</h3>
        <nav aria-label="...">
            <ul class="pagination">
                <li class="page-item disabled">
                    <a class="page-link" href="#" tabindex="-1">Previous</a>
                </li>
                <li class="page-item"><a class="page-link" href="#">1</a></li>
                <li class="page-item active">
                    <a class="page-link" href="#">2 <span class="sr-only">(current)</span></a>
                </li>
                <li class="page-item"><a class="page-link" href="#">3</a></li>
                <li class="page-item">
                    <a class="page-link" href="#">Next</a>
                </li>
            </ul>
        </nav>
    </div>
    <div class="tab-pane" id="messages" role="tabpanel">
        <h3>Messages</h3>
        <nav aria-label="...">
            <ul class="pagination">
                <li class="page-item disabled">
                    <a class="page-link" href="#" tabindex="-1">Previous</a>
                </li>
                <li class="page-item"><a class="page-link" href="#">1</a></li>
                <li class="page-item active">
                    <a class="page-link" href="#">2 <span class="sr-only">(current)</span></a>
                </li>
                <li class="page-item"><a class="page-link" href="#">3</a></li>
                <li class="page-item">
                    <a class="page-link" href="#">Next</a>
                </li>
            </ul>
        </nav>
    </div>
    <div class="tab-pane" id="settings" role="tabpanel">
        <h3>Settings</h3>
        <nav aria-label="...">
            <ul class="pagination">
                <li class="page-item disabled">
                    <a class="page-link" href="#" tabindex="-1">Previous</a>
                </li>
                <li class="page-item"><a class="page-link" href="#">1</a></li>
                <li class="page-item active">
                    <a class="page-link" href="#">2 <span class="sr-only">(current)</span></a>
                </li>
                <li class="page-item"><a class="page-link" href="#">3</a></li>
                <li class="page-item">
                    <a class="page-link" href="#">Next</a>
                </li>
            </ul>
        </nav>
    </div>
</div>

Here are the steps to reproduce the issue:

  • The Home tab loads as active
  • Clicking on Profile tab loads correctly
  • Upon clicking Messages tab, you will notice that the Profile tab is not hidden and both Profile and Messages tabs are visible

I would appreciate any insights into this behavior as well as any quick fix or workaround solutions. Thank you!

Answer №1

The Profile tab wasn't wrapped in the correct li element as shown below:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b4c4dbc4c4d1c69adec7f4859a85809a84">[email protected]</a>/dist/umd/popper.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>

<ul class="nav nav-tabs" id="myTab" role="tablist">
    <li class="nav-item">
        <a class="nav-link active" data-toggle="tab" href="#home" role="tab">Home</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" data-toggle="tab" href="#profile" role="tab">Profile</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" data-toggle="tab" href="#messages" role="tab">Messages</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" data-toggle="tab" href="#settings" role="tab">Settings</a>
    </li>
</ul>

<!-- Tab panes -->
<div class="tab-content">
    <div class="tab-pane active" id="home" role="tabpanel">
        <h3>Home</h3>
        <nav aria-label="...">
            <ul class="pagination">
                <li class="page-item disabled">
                    <a class="page-link" href="#" tabindex="-1">Previous</a>
                </li>
                <li class="page-item"><a class="page-link" href="#">1</a></li>
                <li class="page-item active">
                    <a class="page-link" href="#">2 <span class="sr-only">(current)</span></a>
                </li>
                <li class="page-item"><a class="page-link" href="#">3</a></li>
                <li class="page-item">
                    <a class="page-link" href="#">Next</a>
                </li>
            </ul>
        </nav>
    </div>
    <div class="tab-pane" id="profile" role="tabpanel">
        <h3>Profile</h3>
        <nav aria-label="...">
            <ul class="pagination">
                <li class="page-item disabled">
                    <a class="page-link" href="#" tabindex="-1">Previous</a>
                </li>
                <li class="page-item"><a class="page-link" href="#">1</a></li>
                <li class="page-item active">
                    <a class="page-link" href="#">2 <span class="sr-only">(current)</span></a>
                </li>
                <li class="page-item"><a class="page-link" href="#">3</a></li>
                <li class="page-item">
                    <a class="page-link" href="#">Next</a>
                </li>
            </ul>
        </nav>
    </div>
    <div class="tab-pane" id="messages" role="tabpanel">
        <h3>Messages</h3>
        <nav aria-label="...">
            <ul class="pagination">
                <li class="page-item disabled">
                    <a class="page-link" href="#" tabindex="-1">Previous</a>
                </li>
                <li class="page-item"><a class="page-link" href="#">1</a></li>
                <li class="page-item active">
                    <a class="page-link" href="#">2 <span class="sr-only">(current)</span></a>
                </li>
                <li class="page-item"><a class="page-link" href="#">3</a></li>
                <li class="page-item">
                    <a class="page-link" href="#">Next</a>
                </li>
            </ul>
        </nav>
    </div>
    <div class="tab-pane" id="settings" role="tabpanel">
        <h3>Settings</h3>
        <nav aria-label="...">
            <ul class="pagination">
                <li class="page-item disabled">
                    <a class="page-link" href="#" tabindex="-1">Previous</a>
                </li>
                <li class="page-item"><a class="page-link" href="#">1</a></li>
                <li class="page-item active">
                    <a class="page-link" href="#">2 <span class="sr-only">(current)</span></a>
                </li>
                <li class="page-item"><a class="page-link" href="#">3</a></li>
                <li class="page-item">
                    <a class="page-link" href="#">Next</a>
                </li>
            </ul>
        </nav>
    </div>
</div>

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

What methods can be used to identify the css properties that are overriding ReactJS component styles?

:) I've been working on creating a website for some time now, and I decided to incorporate a react-calendar component from this link. Initially, when the page was simpler, it worked perfectly as intended and displayed like this based on the example p ...

FadeToggle is a jQuery function that allows you to toggle the visibility of an

I'm struggling with creating a dynamic question and answer system on my website. I want the answers to fade in when a user clicks on a specific question, and then fade out when another question is clicked. I was able to achieve this for one paragraph ...

Is it more efficient to pass session variables through an ajax function, or should I access them directly within the script?

I am currently working on a page that utilizes an ajax function to retrieve updates from another page. The function requires the user's id, which is obtained from a session variable, to fetch any new updates. These updates are then displayed in a spec ...

Varied animation response for the secondary background image

Attempting to design a sidebar menu with CSS animations and striving to achieve the maximum without relying on JavaScript or JQuery. However, if necessary, using JS / JQuery is acceptable. The challenge at hand involves an <span></span> elemen ...

Tips for implementing a slide up animation on a dynamic element

I have one div and a button. When the button is clicked, I am appending another div. After appending the second div, I want to add a slide-up animation to the first div and a slide-down animation to the second using jQuery. <div class="main"> & ...

How can you remove the border when an input is in focus on Chrome or Microsoft Edge?

I need to style an input field in a way that removes the black borders/frame that appear around it when clicked on in Chrome and MS Edge. Strangely, Firefox does not display this frame/border. How can I achieve this consistent styling across all browsers? ...

Tips for categorizing items retrieved from .getJSON based on their category property

Looking to display a menu of coffee items with their respective parent categories on the page? Here's how you can start: Category Title Item Item Item Item Category Title Item Item This is what my data model looks like: { "menuItems": [ ...

Issues have been reported with Angular 10's router and anchorScrolling feature when used within a div that is positioned absolutely and has overflow set

I feel like I may be doing something incorrectly, but I can't quite pinpoint the issue. Any help or pointers would be greatly appreciated. My current setup involves Angular 10 and I have activated anchorScrolling in the app-routing.module file. const ...

What causes the columns in my table to move when a Bootstrap collapse is activated?

Utilizing Bootstrap's collapse feature, I want to create an expanding table row that reveals more details. When the row is clicked, the other columns seem to move slightly. It appears that this is somehow related to the length of the details, but I h ...

Adjust the CSS of a different class when the :focus state is triggered

Imagine you have the following code snippet: HTML <div class="container"> <input class="myAwesomeInputBox"> </div> CSS .input [type=text]:focus > .//ANY CLASS SOMEWHERE ON THE WEBSITE{ //Some sweet CSS. } This code does not ...

Having trouble with links not working when using jQuery. Looking to redirect to a different page instead

Using jQuery, I am attempting to display and hide various "tabs" on a webpage. However, my goal is to have the tabs link to different pages, but I haven't been successful in making it work. I have tried looking for a solution, but perhaps I am not us ...

I'm currently working with Bootstrap 5. Is there a technique available to reposition the elements within a div without relying on padding or margin properties?

Developing a Website: <!DOCTYPE html> <html lang="en" class="h-100"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" ...

How can I define the boundaries for the scrolling of a static background image?

Is there a way to limit how far a fixed background image can scroll down a page? Essentially, is it possible to change the background attachment to static when the bottom of the background image is 10px away from the bottom edge of its div container? In t ...

Applying a specified style to a pseudo element using the ::after selector to display an

Can anyone help me with adding a pseudo element ::after containing an icon (from FontAwesome) to my Bootstrap Vue ProgressBar? I want this icon to be dynamic and move along the progress bar line when I click. Here is my current implementation, where the Pr ...

Adaptive grids in Bootstrap

I've been using bootstrap and I'm trying to get the items to align next to each other, but using the bootstrap columns doesn't seem to be working for me. I may be coding it incorrectly. <link rel="stylesheet" href="https://cdn.jsdelivr ...

Encountering issues with extracting JSON data in ReactJS constructor using Jquery due to property of null error

Currently, I am delving into the world of ReactJS in order to create a web application that necessitates the use of Jquery for extracting remote JSON data from a server. The issue arises when attempting to extract this data remotely, as manually inputting ...

Modifying the CSS based on the SQL data retrieved

I'm currently diving into the world of php and jquery, attempting to build a webpage that displays player information and their status fetched from my Mysql server. Although the core code is functional, it's a mashup of snippets gathered from va ...

Using jQuery to smoothly transition the page: first fade out the current content, then switch the background

I'm currently facing an issue with trying to create a step-by-step operation that involves fading the container div around a target div, changing the background, and then fading it back in. The problem is that all the functions in this block are being ...

Using Javascript to extract the date from a specific field and then computing the date of birth

I am currently working on a form which includes a datepicker for the field of birthdate. Additionally, I have an age input field that I want to automatically fill with the person's age based on their birthdate (comparing it to the current date). My m ...

Inversion filter malfunctioning on Internet Explorer and Safari

Having issues with inverting image colors on IE and Safari. I'm working on a navigation feature where images change color when clicked or hovered over, but this functionality isn't working on IE and Safari. A function issue { $('.pressed& ...