を前提に => On the premise of N1
Premise
~ひょうしに(~拍子に)   => the moment [A], unintentionally / inadvertently caused something to happen N1