Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 907c851

Browse files
committed
fix(tab): revert template change
- Reverts template change to tab - Adds warning if one desires more complex HTML inside the tab BREAKING CHANGE: This undoes the prior change to the template using div elements. If one wishes to use div elements, one must override the template in one's app and provide the necessary CSS Closes #5262 Fixes #5254
1 parent de24927 commit 907c851

File tree

4 files changed

+24
-68
lines changed

4 files changed

+24
-68
lines changed

Diff for: src/tabs/docs/readme.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ AngularJS version of the tabs directive.
2323
<i class="glyphicon glyphicon-eye-open"></i>
2424
_(Default: `false`)_ -
2525
Whether tab is currently selected.
26-
26+
2727
* `deselect()`
2828
<small class="badge">$</small>
2929
_(Default: `null`)_ -
@@ -46,3 +46,7 @@ AngularJS version of the tabs directive.
4646
### Tabset heading
4747

4848
Instead of the `heading` attribute on the `uib-tabset`, you can use an `uib-tab-heading` element inside a tabset that will be used as the tabset's header. There you can use HTML as well.
49+
50+
### Known issues
51+
52+
To use clickable elements within the tab, you have override the tab template to use div elements instead of anchor elements, and replicate the desired styles from Bootstrap's CSS. This is due to browsers interpreting anchor elements as the target of any click event, which triggers routing when certain elements such as buttons are nested inside the anchor element.

Diff for: src/tabs/tabs.css

-48
This file was deleted.

Diff for: src/tabs/test/tabs.spec.js

+18-18
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ describe('tabs', function() {
6161
it('should create clickable titles', function() {
6262
var t = titles();
6363
expect(t.length).toBe(2);
64-
expect(t.find('> div').eq(0).text()).toBe('First Tab 1');
64+
expect(t.find('> a').eq(0).text()).toBe('First Tab 1');
6565
//It should put the uib-tab-heading element into the 'a' title
66-
expect(t.find('> div').eq(1).children().is('uib-tab-heading')).toBe(true);
67-
expect(t.find('> div').eq(1).children().html()).toBe('<b>Second</b> Tab 2');
66+
expect(t.find('> a').eq(1).children().is('uib-tab-heading')).toBe(true);
67+
expect(t.find('> a').eq(1).children().html()).toBe('<b>Second</b> Tab 2');
6868
});
6969

7070
it('should bind tabs content and set first tab active', function() {
@@ -76,7 +76,7 @@ describe('tabs', function() {
7676
});
7777

7878
it('should change active on click', function() {
79-
titles().eq(1).find('> div').click();
79+
titles().eq(1).find('> a').click();
8080
expect(contents().eq(1)).toHaveClass('active');
8181
expect(titles().eq(0)).not.toHaveClass('active');
8282
expect(titles().eq(1)).toHaveClass('active');
@@ -85,17 +85,17 @@ describe('tabs', function() {
8585
});
8686

8787
it('should call select callback on select', function() {
88-
titles().eq(1).find('> div').click();
88+
titles().eq(1).find('> a').click();
8989
expect(scope.selectSecond).toHaveBeenCalled();
90-
titles().eq(0).find('> div').click();
90+
titles().eq(0).find('> a').click();
9191
expect(scope.selectFirst).toHaveBeenCalled();
9292
});
9393

9494
it('should call deselect callback on deselect', function() {
95-
titles().eq(1).find('> div').click();
96-
titles().eq(0).find('> div').click();
95+
titles().eq(1).find('> a').click();
96+
titles().eq(0).find('> a').click();
9797
expect(scope.deselectSecond).toHaveBeenCalled();
98-
titles().eq(1).find('> div').click();
98+
titles().eq(1).find('> a').click();
9999
expect(scope.deselectFirst).toHaveBeenCalled();
100100
});
101101
});
@@ -181,13 +181,13 @@ describe('tabs', function() {
181181
execOrder = [];
182182

183183
// Select second tab
184-
titles().eq(1).find('> div').click();
184+
titles().eq(1).find('> a').click();
185185
expect(execOrder).toEqual([ 'deselect1', 'select2' ]);
186186

187187
execOrder = [];
188188

189189
// Select again first tab
190-
titles().eq(0).find('> div').click();
190+
titles().eq(0).find('> a').click();
191191
expect(execOrder).toEqual([ 'deselect2', 'select1' ]);
192192
});
193193
});
@@ -277,7 +277,7 @@ describe('tabs', function() {
277277
});
278278

279279
it('should switch active when clicking', function() {
280-
titles().eq(3).find('> div').click();
280+
titles().eq(3).find('> a').click();
281281
expectTabActive(scope.tabs[3]);
282282
});
283283

@@ -344,7 +344,7 @@ describe('tabs', function() {
344344
}));
345345

346346
function heading() {
347-
return elm.find('ul li > div').children();
347+
return elm.find('ul li > a').children();
348348
}
349349

350350
it('should create a heading bound to myHtml', function() {
@@ -406,7 +406,7 @@ describe('tabs', function() {
406406

407407
it('should preserve correct ordering', function() {
408408
function titles() {
409-
return elm.find('ul.nav-tabs li > div');
409+
return elm.find('ul.nav-tabs li > a');
410410
}
411411
scope.$apply();
412412
expect(titles().length).toBe(9);
@@ -549,7 +549,7 @@ describe('tabs', function() {
549549
expectContents(['Hello', 'content 1', 'content 2', 'content 3']);
550550

551551
// Select last tab
552-
titles().find('> div').eq(3).click();
552+
titles().find('> a').eq(3).click();
553553
expect(contents().eq(3)).toHaveClass('active');
554554
expect(titles().eq(3)).toHaveClass('active');
555555

@@ -563,7 +563,7 @@ describe('tabs', function() {
563563
expect(contents().eq(2)).toHaveClass('active');
564564

565565
// Select 2nd tab ("tab 1")
566-
titles().find('> div').eq(1).click();
566+
titles().find('> a').eq(1).click();
567567
expect(titles().eq(1)).toHaveClass('active');
568568
expect(contents().eq(1)).toHaveClass('active');
569569

@@ -659,10 +659,10 @@ describe('tabs', function() {
659659
}
660660

661661
it('should not switch active when clicking on title', function() {
662-
titles().eq(2).find('> div').click();
662+
titles().eq(2).find('> a').click();
663663
expectTabActive(scope.tabs[2]);
664664

665-
titles().eq(3).find('> div').click();
665+
titles().eq(3).find('> a').click();
666666
expectTabActive(scope.tabs[2]);
667667
});
668668

Diff for: template/tabs/tab.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<li ng-class="{active: active, disabled: disabled}" class="uib-tab">
2-
<div ng-click="select()" uib-tab-heading-transclude>{{heading}}</div>
2+
<a href ng-click="select()" uib-tab-heading-transclude>{{heading}}</a>
33
</li>

0 commit comments

Comments
 (0)