If you preview a section link to the page itself then clicking it will go to the edit page itself so the link can be tried in context without reloading the page. That makes sense.
But if you open the link in a new tab or window, e.g. in a section edit where you are trying to test a link to another section, then it means you open a new edit page and the section link doesn't work.
Can something be done about this? For example, attach a certain parameter to such selflinks in previews. If an edit url is loaded with this parameter then ignore the edit part of the url and display the wiki page instead.
The issue can be tested by previewing this on https://en.wikipedia.org/wiki/Wikipedia:Sandbox with the source editor:
== Heading == Links to the above heading: * [[Wikipedia:Sandbox#Heading]] * [[#Heading]]
Both links work when clicked normally but not when opened in a new browser tab or window which gives me:
https://en.wikipedia.org/w/index.php?title=Wikipedia:Sandbox&action=submit#Heading
I suggest you instead get https://en.wikipedia.org/wiki/Wikipedia:Sandbox#Heading like if you had previewed the first link from any other page or saved the code before clicking any of the two links. A url variation with the same result would also be fine: https://en.wikipedia.org/w/index.php?title=Wikipedia:Sandbox#Heading