Wiring – How to connect a new fixture to a box with two black and two white wires

light-fixturelightingwiring

I am attempting to change/update a chandelier in our dining room. I (mistakenly) disconnected the previous fixture without noting the connection first. When I attempted to connect the next chandelier (all the blacks to blacks, all the whites to whites, and copper to ground w/ fixture grounded) and flip the breaker switch, the light comes on BUT the switch is off and won't turn off unless I flip the breaker switch.

The new fixture only has 1 black, 1 white and a ground. How should the connection be? In the picture the yellow cap indicates the wire that when connected, provides power but won't turn off. Any help would be appreciated! Thank you!

enter image description here

Best Answer

Assuming only one fixture controlled by that switch, you seem to have a typical switch loop here. Connect per this diagram:

enter image description here