Skip to content

.show class leaked on navlink #28118

Description

@ntd

Bootstrap 4.2.1: on every dynamic tabbed interface, whenever I click on a .tablink the classes .active .show are properly added to the new item but the .show class is not removed from the previously active item. If this is an issue, it seems to be a regression because with bootstrap 4.1.3 all is working as expected.

Here is a MWE using pills; just inspect Home or Profile while switching between the two panes: https://jsfiddle.net/4oy92hmx/

Activity

  1. XhmikosR commented on Jan 25, 2019

    @XhmikosR
    Member

    /CC @Johann-S

    Must be a regression from #27533

  2. Johann-S commented on Jan 28, 2019

    @Johann-S
    Member

    Yep I think too, maybe @MartijnCuppens wants to fix that ?

  3. XhmikosR commented on Feb 2, 2019

    @XhmikosR
    Member

    @MartijnCuppens: any progress with this?

  4. MartijnCuppens commented on Feb 2, 2019

    @MartijnCuppens
    Member

    I forgot about this, I'll have a look at it now and check if we can write a test to prevent this from happening.

  5. MartijnCuppens commented on Feb 2, 2019

    @MartijnCuppens
    Member

    Reverting https://github.com/twbs/bootstrap/pull/27533/files#diff-02a6d2619ddbbd65ac148de3377674eeL174 would indeed "fix" this issue, but there's another issue here: we shouldn't add the .show class on the .nav-link in any case.

    Let's analyse these lines:

    bootstrap/js/src/tab.js

    Lines 111 to 133 in f134d4b

    this._activate(
    this._element,
    listElement
    )
    const complete = () => {
    const hiddenEvent = $.Event(Event.HIDDEN, {
    relatedTarget: this._element
    })
    const shownEvent = $.Event(Event.SHOWN, {
    relatedTarget: previous
    })
    $(previous).trigger(hiddenEvent)
    $(this._element).trigger(shownEvent)
    }
    if (target) {
    this._activate(target, target.parentNode, complete)
    } else {
    complete()
    }

    The _activate function is triggered on .tab-pane and .nav-link. In L111 the show class will be added to the target .tab-pane and in L130 the class will be added to the .nav-link. Not sure why.

    @Johann-S could you help here?

  6. removed their assignment
    on Feb 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions