Player floats in air when jumping and not moving.

So my player has a Character Controller component and a script playermovementcontroller. The problem is when I jump and not hold any movement key like W the player stops and stays in the air for so long when I move again with the movement keys. I got the movement script from Brackeys tutorial and jump script from docs: Unity - Scripting API: CharacterController.Move .
I think the problem is that the controller.Move is not updating when not holding any key, so I added else if and updated again controller.Move(playerVel * Time.deltaTime) this time, under the if(moveDir.magnitude >= 0.1f) and it worked good. However I don’t know if I should do this like that.

It’s because you are moving your player only when (moveDir.magnitude >= 0.1f), try move your controller.Move method in line 40 for outside the if statement