I've fixed this for the mentioned case, which is the most likely to occur.
However, it is still possible to cause problems by joining a team, cancelling back (from the hero menu), and then cancelling again. This causes you to spawn as the first player on your team, but not everything is necessarily set up for this player. A new bug should be written up to prevent this (probably by setting the player back to spectator before exiting the menu).
If this ever occurs, it is possible to start over by pulling up the team menu (via "chooseteam" command), and selecting through the items.
I've fixed this for the mentioned case, which is the most likely to occur.
However, it is still possible to cause problems by joining a team, cancelling back (from the hero menu), and then cancelling again. This causes you to spawn as the first player on your team, but not everything is necessarily set up for this player. A new bug should be written up to prevent this (probably by setting the player back to spectator before exiting the menu).
If this ever occurs, it is possible to start over by pulling up the team menu (via "chooseteam" command), and selecting through the items.