It happens both on battery and on charge for me..It's odd this is happening for you whilst it's on charge. I don't have issues unlocking while on charge, only when it's on battery only mode.
I'll test this again today in case anything has changed. over the last few days.
I noticed it's a matter of time. If you let it sleep for a minute or two it won't do this glitch, but if you let it sleep lets say for 20 min or something it will do that glitch always.