Fix index out of bounds error in TextMenu.