Light Fixture box with 3 sets of wires (confusing wiring)

light-fixture

I recently took off a light fixture in my home's bathroom and before I could take mental note of the wiring situation, the white wire from the fixture slipped from a wire nut (not a great sign of previous electrical work, I know..). The black wire from the fixture was connected to the single black wire on the right side of the box (presumably the switch's cable) but I do not know where the fixture's white wire was connected. I have a feeling the white wire from the fixture was connected to the two black wires on the left side of the picture, however, I'm hesitant to do that (I added the electrical tape for now). Note that the fixture/switch were working perfectly fine. Any thoughts on where the white wire from the fixture needs to be attached? Thanks in advance

Box & wiring

Best Answer

What you've got here is power in to the fixture box, power out to whatever is next and a "switch leg" cable to the switch. You are probably right that the wires from the fixture were connected to the blacks with the wire nuts. Unfortunately this isn't best practice, dangerous at best. This setup leaves the fixture "hot" all the time and effectively interrupts the neutral.

The way to make it right is to connect the right black wire with the 2 on the left. Disconnect the white wires and code tape black the white wire coming back from the switch. Connect that to the black wire on the fixture and the other wire (white) from the fixture to the other white wires. Best practice would be pigtail the whites so you only have one wire to deal with when installing the fixture.

Oh and get a wire nut on those ground wires while you're in there!