If a buyer has "to sell" their home before they can buy yours - that means they first have to secure a buyer - negotiate - obtain an offer - then go through the process of home inspections, further negotiations..... and perhaps a 30+ day period of time for their buyers to be approved for a loan..........that's weeks, maybe months, down the road before you will have a solid deal with them......
Why not tell these "not-quite-ready-to-buy-yet- buyers to come back when they are able to make a bonafide offer minus that kind of contingency?
It will be cleaner and neater to do that, rather than trying to create a contract giving you an out, or them the right of first refusal, or however you want to state it.
In the meantime, you can be open and available for a real buyer who can move forward now, not later!
If they sell their house, and don't have any contingencies on that sale, then let them come back to you.
If you have an agent, please defer to his or her advice!