I work backwards and base on affordability. Take Net income after pension, tax, cycle to work etc.
Deduct living costs (food, childcare, car costs, insurance, holidays, debt repayments, medical costs) and see what your disposable non-rent or mortgage budget is.
Now use a mortgage calculator to see how much that is for repayments, but allow headroom for a mortgage rate increase. IIRC stress tests before COVID were to 7% but I'd probably go to 8 or 9 today.
Possibly boring and sensible, but home security is a big thing for me.
E.g 4600 net might mean £2000 repayment might be comfortable. That's £350,000 at 5% over 25 years.
However if interest rates go to 8% the repayment is 2701 per month which is too much in my view.
300k at 8% over 25 years is £2,315 which might be more sensible.
Depends on your risk appetite, expected future earnings, do you have 25 years until retirement, etc etc.