Gameobject doesn’t move when hits wall

I have a gameobject that moves tile based(It moves 1 unity unit continously when I press button) But when ıt hits a wall, ıt doesn’t move anymore

enter image description here

As you see, When It hits a wall, ıt doesn’t move any direction anymore. Actually I found the problem but I couldn’t find how to solve. The main problem is when cube hits wall, the distance between nextPosition and transform.position never will be <0.0005f But Idk how to solve this.

Those are code that moves cube :

void MovePlayer() {     rb.MovePosition(Vector3.MoveTowards(transform.position, nextPosition, speed * Time.deltaTime));      if (Input.GetKeyDown(KeyCode.W))     {         direction = Vector3.forward;     }      if (Input.GetKeyDown(KeyCode.S))     {         direction = Vector3.back;     }      if (Input.GetKeyDown(KeyCode.A))     {         direction = Vector3.left;     }      if (Input.GetKeyDown(KeyCode.D))     {         direction = Vector3.right;     }      if (Vector3.Distance(transform.position, nextPosition) < 0.0005f)     {         nextPosition = transform.position + direction;     } }