Make tab overflow behavior more robust

Fix #972 and address a couple of other edge cases with overflow (related to dragged tabs sometimes being incorrectly sorted into dropdown list when they were the last element in the main tab list).