Switch weird error

Hello everyone!
My switch recently started to suffer from a weird error that i can’t pinpoint. Whenever i play a game it randomly dimms the screen, a low battery logo appears in the middle of the screen and then it goes to sleep. My battery is still healthy and can play in handheld mode for a fair amount of time, it charges normally also it does this even if the switch is plugged in or docked. I tried google and forums but in vain. It’s annoying when playing an online game. If someone has bumped into this error before and can guide me….