Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tabs: fix nested tabs. #23087

Merged
merged 4 commits into from
Aug 11, 2017
Merged

tabs: fix nested tabs. #23087

merged 4 commits into from
Aug 11, 2017

Conversation

XhmikosR
Copy link
Member

@XhmikosR XhmikosR commented Jul 14, 2017

When one uses say a carousel inside a tab, the .active selector previously matches the carousel ones too leading to broken tabs.

It's not the perfect solution but should the job for now.

/CC @Johann-S

PS. The data-target solution you suggested seems definitely better for the long term. I just don't have the time to implement it myself so I resorted to a quick fix for now :)

Fixes #22654.

@XhmikosR
Copy link
Member Author

...and tests fail :D

@Johann-S
Copy link
Member

Test failed because with this change this line :

previous = $.makeArray($(listElement).find(Selector.ACTIVE))

Retrieve nothing, so we are unable to find previous active items

@XhmikosR
Copy link
Member Author

I should probably also add a test for my use case that currently fails.

@Johann-S: feel free to push to this branch if you have any ideas.

Copy link
Member

@Johann-S Johann-S left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Unless @XhmikosR want to add another unit test here

@mdo
Copy link
Member

mdo commented Jul 17, 2017

Slating this for Beta 2. Thanks for tackling it!

@XhmikosR
Copy link
Member Author

@Johann-S: I just tested this and indeed fixes the issue for my use case. Not sure if I should add my test case though.

@mdo: this is a regression I believe. So it shouldn't be postponed.

@mdo
Copy link
Member

mdo commented Jul 17, 2017

@mdo: this is a regression I believe. So it shouldn't be postponed.

We're going to have things we've broken in the beta—we won't have a perfect ship—and this isn't critical IMO. The remaining time ahead of Beta 1 should be spent on ensuring nothing that is current broken (or working hah) needs a backwards incompatible change.

@danijelGombac
Copy link

This fix is also not good for my nested tabs. I stick with

ACTIVE_CHILD : '> .nav-item > .active, > .active',

from alpha 6 tabs.

@Johann-S
Copy link
Member

I'll check that thank you @danijelGombac for the feedback 👍

@danijelGombac
Copy link

I made different tabs with collapse inside. Maybe i should make different codepen.

@Johann-S
Copy link
Member

It seems it works pretty well here : https://codepen.io/Johann-S/pen/zzQEje
with my changes

@danijelGombac
Copy link

Later i make a codepen, so you can see what is wrong and if tabs will support this type of approach.

@Johann-S
Copy link
Member

Yes do not hesitate to provide a reduce test case @danijelGombac 👍

@danijelGombac
Copy link

Tabs with collapse. Look Product discounts tab. There is also problem with bg colors.

https://codepen.io/danijelGombac/pen/yXWKdL

@Johann-S
Copy link
Member

I made a fix for your issue @danijelGombac but I didn't handled the problem with background colors

@danijelGombac
Copy link

Ok, i will test it. The background color problem lies in this part of code:

.nav-pills {
  .nav-link {
    @include border-radius($nav-pills-border-radius);

    &.active,
    .show > & {
      color: $nav-pills-link-active-color;
      background-color: $nav-pills-link-active-bg;
    }
  }
}

Come out:

.nav-pills .nav-link.active,
.show > .nav-pills .nav-link {
  color: #fff;
  background-color: #007bff;
}

And when collapse became collapse.show change all .nav-links.

@Johann-S
Copy link
Member

Maybe this CSS issue should be solved in an other PR

@danijelGombac
Copy link

@Johann-S

I try your code, but still something not working well. You can see in the last two tabs. When you click the last two tabs and then the tab with collapse, they remain active and from the tabs in collapse the active state is removed.

https://codepen.io/danijelGombac/pen/yXWKdL

@Johann-S Johann-S force-pushed the v4-dev-xmr-tabs-fix branch from b838f32 to 963721e Compare July 19, 2017 17:20
@Johann-S
Copy link
Member

I made a new commit @danijelGombac which should fix your issue 😉

@danijelGombac
Copy link

I try the code and seems to work fine. 👍

@Johann-S Johann-S force-pushed the v4-dev-xmr-tabs-fix branch from 963721e to f5e63d7 Compare July 20, 2017 09:24
@Johann-S
Copy link
Member

Johann-S commented Jul 20, 2017

I made a bit of refactorization here :

      let activeElements
      if (callback === undefined) {
        if (container.nodeName === 'UL') {
          activeElements = $(container).find(Selector.ACTIVE_UL)
        } else {
          activeElements = $(container).find(Selector.ACTIVE)
        }
      } else {
        activeElements = $(container).children(Selector.ACTIVE)
      }

changed to :

      let activeElements
      if (container.nodeName === 'UL') {
        activeElements = $(container).find(Selector.ACTIVE_UL)
      } else {
        activeElements = $(container).children(Selector.ACTIVE)
      }

I played every CodePen submited by @danijelGombac and everythings works fine, Unit tests passed, if you have time @XhmikosR to check on your personal use case too it would be great 👍
I promise it's the last time I change this code (on this PR 😆)

@XhmikosR
Copy link
Member Author

@Johann-S: there's a regression somewhere again, I'll ping you on Slack.

@Johann-S
Copy link
Member

@mdo we have a question (@XhmikosR and myself) about our Tabs plugins, we aren't sure if our Tabs plugin should handle a markup like this with the .active class on the li element instead of the a element :

<ul class="nav nav-tabs nav-justified" role="tablist">
  <li class="nav-item">
    <a href="#home" class="nav-link" role="tab" data-toggle="tab">Home</a>
  </li>
  <li class="nav-item active">
    <a href="#options" class="nav-link" role="tab" data-toggle="tab">Options</a>
  </li>
  <li class="nav-item">
    <a href="#team" class="nav-link" role="tab" data-toggle="tab">Team</a>
  </li>
</ul>
<div class="tab-content">
  <div id="home" role="tabpanel" class="tab-pane fade">
    Home
  </div>
  <div id="options" role="tabpanel" class="tab-pane fade show active">
    Options
  </div>
  <div id="team" role="tabpanel" class="tab-pane fade">
    Team
  </div>
</div>

@XhmikosR do not hesitate to add some details 👍

@XhmikosR XhmikosR deleted the v4-dev-xmr-tabs-fix branch August 11, 2017 12:14
@mdo mdo mentioned this pull request Aug 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants