Did I do the right thing?

A while ago I was in a happy and healthy relationship. Then one day, I met another guy with whom I felt an instant connection. When I realized I was getting feelings for this other guy, I broke things off with my boyfriend at the time. For outside reasons, I can’t have a serious relationship with the guy I met anyways, but I didn’t want to stay with my boyfriend while having feelings for someone else. I don’t know if I made the right decision when my previous relationship was perfectly fine, or if I should have just waited a while for my infatuation with the other guy to go away. What would you have done?