Page MenuHomePhabricator

Links to anchors behave differently on page preview
Closed, InvalidPublic

Description

Author: rui.hamilton.abreu

Description:
A link to an section heading, such as link to anchor, does not behave properly when the page is being previewed. It produces a URL to the page's name but, at the end of the URL, instead of "#Anchor" being added, "&action=submit#Anchor" is added.


Version: 1.16.x
Severity: minor

Details

Reference
bz24177

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:07 PM
bzimport set Reference to bz24177.
bzimport added a subscriber: Unknown Object (MLST).

This is proper behavior. The generated HTML is something like <a href="#Anchor">link to anchor</a> , which links to #Anchor on the current page. It so happens that the URL of the current page ends in &action=submit , so the browser builds a URL that ends in &action=submit#Anchor .

I'm coming from mediawikiwiki: I've corrected in this manner: http://www.mediawiki.org/w/index.php?title=Help%3ALinks&action=historysubmit&diff=334915&oldid=334870 but maybe Hamilton Abreu's edit can be just reverted.

rui.hamilton.abreu wrote:

The edit at mediawiki.org has been rolled back. So as to be clear, the issue was initially raised because I was following the anchor link by opening it in a new tab, rather than simply just clicking it. This, of course, comes from a habit acquired way before the "are you sure you want to navigate away from this page" warning. You send everything to new tabs, in order not to ever disrupt the edit while previewing it. I actually believe most users do the same, but anyway... the mentioned effect then ensues.

rui.hamilton.abreu wrote:

For the benefit of anyone unaware of the effect, if the abbreviated anchor link is opened in a new tab during page preview of the edit, instead of jumping to the anchored section of the page the original text is again opened for editing, due to the &action=submit#Anchor ending of the URL.

If, instead of abbreviating the URL, the full pagename is used, then the original text (not the edit being previewed) is opened in the new tab and the browser jumps to the anchored section, if it existed in the original text. So, opening anchors in new tabs never fully works as one might initially have expected.

Thanks to all and apologies for the time I may have caused you to waste.