similar scenario.
you are on a SID with a 5000 or below restriction at XYZ. your clearance is climb to 7000. your intention is to stop climb at 5000 until passing XYZ however before you get to XYZ you are given a hdg (which happens to be the hdg towards XYZ)
do you level off at 5000 until passing XYZ in this case?
I would climb straight to 7000 before XYZ as I am on a vector and no longer on the SID.