Skip to content

Commit

Permalink
Tabs: Find panels using aria-controls instead of index for remove met…
Browse files Browse the repository at this point in the history
…hod. Fixes #7698 - Panels do not sort when a tab is sorted which can cause a mismatch error when a tab is removed.
  • Loading branch information
scottgonzalez committed Sep 6, 2011
1 parent 08450c3 commit c1cda18
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ui/jquery.ui.tabs.js
Expand Up @@ -792,11 +792,14 @@ if ( $.uiBackCompat !== false ) {
index = this._getIndex( index );
var options = this.options,
tab = this.lis.eq( index ).remove(),
panel = this.panels.eq( index ).remove();
panel = this._getPanelForTab( tab.find( "a[aria-controls]" ) ).remove();

// If selected tab was removed focus tab to the right or
// in case the last tab was removed the tab to the left.
if ( tab.hasClass( "ui-tabs-active" ) && this.anchors.length > 1) {
// We check for more than 2 tabs, because if there are only 2,
// then when we remove this tab, there will only be one tab left
// so we don't need to detect which tab to activate.
if ( tab.hasClass( "ui-tabs-active" ) && this.anchors.length > 2 ) {
this._activate( index + ( index + 1 < this.anchors.length ? 1 : -1 ) );
}

Expand Down

0 comments on commit c1cda18

Please sign in to comment.