Skip to content

Commit

Permalink
sync activeIndex when inserting/removing before current activeIndex (…
Browse files Browse the repository at this point in the history
…fixes 2528781)
  • Loading branch information
msweeney committed Feb 24, 2011
1 parent a86f2c4 commit e232a2b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
7 changes: 7 additions & 0 deletions build/tabview/tabview-debug.js
Expand Up @@ -92,6 +92,7 @@
contentParent = this._contentParent,
tabElement = tab.get(ELEMENT),
contentEl = tab.get(CONTENT_EL),
activeIndex = this.get(ACTIVE_INDEX),
before;

if (!tabs) { // not ready yet
Expand All @@ -118,6 +119,9 @@

if ( !tab.get(ACTIVE) ) {
tab.set('contentVisible', false, true); /* hide if not active */
if (index <= activeIndex) {
this.set(ACTIVE_INDEX, activeIndex + 1, true);
}
} else {
this.set(ACTIVE_TAB, tab, true);
this.set('activeIndex', index, true);
Expand Down Expand Up @@ -205,6 +209,7 @@
*/
removeTab: function(tab) {
var tabCount = this.get('tabs').length,
activeIndex = this.get(ACTIVE_INDEX),
index = this.getTabIndex(tab);

if ( tab === this.get(ACTIVE_TAB) ) {
Expand All @@ -217,6 +222,8 @@
} else { // no more tabs
this.set(ACTIVE_TAB, null);
}
} else if (index < activeIndex) {
this.set(ACTIVE_INDEX, activeIndex - 1, true);
}

this._removeTabEvents(tab);
Expand Down

0 comments on commit e232a2b

Please sign in to comment.