USB has sleep/suspend mode options. Conceivably, the phone has received the suspend signal over the data pair, and stops charging. This is very much dependent on the phone, the computer's hardware design, and the computer's OS though, so it is just conjecture. USB Suspend specification requires a maximum of 500µA, some of which is taken by the pull-up/pull-down resistors that are part of the USB spec.
Easy enough to test though, get a second regular (data+charging) cable, and try it with that. If it also stops charging when the computer goes to sleep, then it's normal. If it doesn't, it would be an issue with the first cable.
As for why the power only cable still works, your computer has standby power on USB, the data lines are not connected, so the phone believe it is on a regular usb charger (it has no way to tell the difference). If the power is there, the phone will take it.