Nintendo Switch game disconnects when charging in sleep mode

I’m having a strange problem with my Nintendo switch lately. When I play a game, then put it on the charger after a while of it being in sleep mode the game disconnects and I have to take the game out and put it back in before it works again. It isn’t that much of a major problem its just a bit of an inconvenience and was wondering if anyone knows how to solve this issue