You don’t get practice swings during play, and the ball was still live. The pitcher released the ball, and it was still moving in fair territory when the batter swung. That is a rulebook strike, and the umpire has to call that no matter how silly it looks.