As far as I know, that is only the case when you move as a spanish tax resident to a tax haven like p.e Bahamas.
In this case, you also have to prove that you spent at least 183 days there in the year you left.
Moving to another low tax country within the EU is not a problem and without this restriction.
Sources:
"Individuals of Spanish nationality who accredit their new fiscal residence in a country or
territory labelled as a tax haven will not lose their status as taxpayers for Individual Income Tax.
This rule is of application during the tax period in which the change of residence occurs and for
the next four tax periods"
"In a recent judgement dated 16-06-2011, the Supreme Court (TS) reiterated the criterion applied in other prior judgements in relation to the concept of tax residency in Spain for people wishing to leave Spain. This judgement examined the case of an elite sportsperson who wished to establish their residence for tax purposes in Andorra, a country regarded as a tax haven by Spanish authorities. The reason was preventing Spain from taxing this person’s income under the worldwide income rule.
The judgement concluded that, in order to accept the abandonment of the Spanish territory, proof is required of a minimum physical stay of 183 days in the other country. Furthermore, the fact that Andorra is a tax haven means that sporadic absences don’t need to be recorded (short stays in other countries), and this means that it is easier to reach the 183-day figure in Spain."
"In the case of countries or territories
labelled as tax havens, the Tax Administration can demand proof of stay in that tax haven over a
period of 183 days within the calendar year."
https://www.oecd.org/tax/automatic-...istance/tax-residency/SPAIN-Tax-Residency.pdf