I had the exact same issue (made a thread about it). If the joycon doesn't detect that it's directly attached to the Switch, it's almost certainly a problem with the bottom ribbon cable that connects the rail to the motherboard. From what I understand, this bottom ribbon cable controls the physical connection between the joycon and the Switch itself, and is used for charging, syncing, etc. In my case, I had a bent pin in the connector that the ribbon cable goes into. Bending it into place solved the problem.