Skip to content

Commit f1fa076

Browse files
committed
Tabs: Don't blur focused tab on sort
Fixes #14627 Closes gh-1761
1 parent 0627eb3 commit f1fa076

File tree

Image for: File tree

1 file changed

Image for: 1 file changed
+12
-1
lines changed

1 file changed

Image for: 1 file changed
+12
-1
lines changed

‎demos/tabs/sortable.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,21 @@
99
<script src="../../external/requirejs/require.js"></script>
1010
<script src="../bootstrap.js" data-modules="sortable">
1111
var tabs = $( "#tabs" ).tabs();
12+
var previouslyFocused = false;
13+
1214
tabs.find( ".ui-tabs-nav" ).sortable({
1315
axis: "x",
14-
stop: function() {
16+
17+
// Sortable removes focus, so we need to restore it if the tab was focused
18+
// prior to sorting
19+
start: function(event, ui) {
20+
previouslyFocused = document.activeElement === ui.item[ 0 ];
21+
},
22+
stop: function(event, ui) {
1523
tabs.tabs( "refresh" );
24+
if (previouslyFocused) {
25+
ui.item.focus();
26+
}
1627
}
1728
});
1829
</script>

0 commit comments

Image for: 0 commit comments
Comments
 (0)