Skip to content
Permalink
Browse files

Fixed #4960 - Tabs: wrong selected tab index

  • Loading branch information...
rdworth committed Dec 31, 2009
1 parent 5ab4b61 commit 41749bf12209157475806cfe0a4e6d37c5a06bf1
Showing with 12 additions and 2 deletions.
  1. +10 −1 tests/unit/tabs/tabs_events.js
  2. +2 −1 ui/jquery.ui.tabs.js
@@ -30,7 +30,16 @@ test('show', function() {
});

test('add', function() {
ok(false, "missing test - untested code is broken code.");

var el = $('<div id="tabs"><ul></ul></div>').tabs();
equals(el.tabs('option', 'selected'), -1, 'Initially empty, no selected tab');

el.tabs('add', '#test1', 'Test 1');
equals(el.tabs('option', 'selected'), 0, 'First tab added should be auto selected');

el.tabs('add', '#test2', 'Test 2');
equals(el.tabs('option', 'selected'), 0, 'Second tab added should not be auto selected');

});

test('remove', function() {
@@ -150,7 +150,7 @@ $.widget("ui.tabs", {
if (typeof o.selected != 'number' && this.lis.filter('.ui-tabs-selected').length) {
o.selected = this.lis.index(this.lis.filter('.ui-tabs-selected'));
}
o.selected = o.selected || 0;
o.selected = o.selected || this.lis.length ? 0 : -1;
}
else if (o.selected === null) { // usage of null is deprecated, TODO remove in next release
o.selected = -1;
@@ -468,6 +468,7 @@ $.widget("ui.tabs", {
this._tabify();

if (this.anchors.length == 1) { // after tabify
o.selected = 0;
$li.addClass('ui-tabs-selected ui-state-active');
$panel.removeClass('ui-tabs-hide');
this.element.queue("tabs", function() {

0 comments on commit 41749bf

Please sign in to comment.
You can’t perform that action at this time.