Skip to content

Commit c1cda18

Browse files
committed
Tabs: Find panels using aria-controls instead of index for remove method. Fixes #7698 - Panels do not sort when a tab is sorted which can cause a mismatch error when a tab is removed.
1 parent 08450c3 commit c1cda18

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ui/jquery.ui.tabs.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,11 +792,14 @@ if ( $.uiBackCompat !== false ) {
792792
index = this._getIndex( index );
793793
var options = this.options,
794794
tab = this.lis.eq( index ).remove(),
795-
panel = this.panels.eq( index ).remove();
795+
panel = this._getPanelForTab( tab.find( "a[aria-controls]" ) ).remove();
796796

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

0 commit comments

Comments
 (0)