During testing with A4988 stepper driver + 24BYJ28 12V stepper motor, it seems the DIR pin is not changing direction properly. This resulted in random shifts due to skipped steps or moves in the opposite direction.
This phenomenon was not observed when using A4988 with NEMA17 stepper motors.
If anyone experiences the same issues, please report your setup here.