Can't concentrate to focus, until it's last minute or later

Basically, I can’t make me to focus on my work until it’s really close to the deadline of my task or even later. I keep procrastinating or code other things, but the one task that I know is my highest priority and the one that should be done, always gets ignored until last minute… Anyone else had this?