Joy con nintendo switch

Hey guys, my joy con is having a bad connection with the switch when it is on the switch but when it is off the switch, playing on the dock the joycon works normally, what can it be?