Skip to content

Commit

Permalink
Tabs: Don't blur focused tab on sort
Browse files Browse the repository at this point in the history
Fixes #14627
Closes gh-1761
  • Loading branch information
scottgonzalez committed Oct 12, 2016
1 parent 0627eb3 commit f1fa076
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion demos/tabs/sortable.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,21 @@
<script src="../../external/requirejs/require.js"></script>
<script src="../bootstrap.js" data-modules="sortable">
var tabs = $( "#tabs" ).tabs();
var previouslyFocused = false;

tabs.find( ".ui-tabs-nav" ).sortable({
axis: "x",
stop: function() {

// Sortable removes focus, so we need to restore it if the tab was focused
// prior to sorting
start: function(event, ui) {
previouslyFocused = document.activeElement === ui.item[ 0 ];
},
stop: function(event, ui) {
tabs.tabs( "refresh" );
if (previouslyFocused) {
ui.item.focus();
}
}
});
</script>
Expand Down

0 comments on commit f1fa076

Please sign in to comment.