The issue was the oil pressure sensor is (usually) in the filter housing, the first oil to hit the sensor is taken from the oil filter.
if you just put the new filter on empty, all sensor gets initially is air - so no oil pressure - & the oil light comes on until the oil gets in there.
Its unlikely that you have damaged anything, so don't worry.
Good old school practice to minimise this is get some oil into the new filter, I try to get mine 2/3rds full.