Fix possible selection bug after closing tab

This commit is contained in:
Dan Stillman 2020-09-17 21:37:34 -04:00
parent a89f7e8ec7
commit a47d7e4d9c

View file

@ -63,7 +63,7 @@ const TabBar = forwardRef(function (props, ref) {
var newTabs = [...tabs];
newTabs.splice(index, 1);
setTabs(newTabs);
setSelectedIndex(selectedIndex - 1);
setSelectedIndex(Math.min(selectedIndex, newTabs.length - 1));
if (props.onTabClosed) {
props.onTabClosed(index);
}