Forums de discussion

Link with anchor: senna.js drops the anchor

thumbnail
Alessandro Candini, modifié il y a 7 années.

Link with anchor: senna.js drops the anchor

Regular Member Publications: 130 Date d'inscription: 17/10/15 Publications récentes
In my local Liferay 7 DXP installation, I've created a web content with the following link:
<a href="http://localhost:8080/en/web/my_site/my_other_page#my_anchor">
    my_other_page#my_anchor
</a>

The problem is that when I click on it, Senna.js parses the href and leads me to http://localhost:8080/en/web/my_site/my_other_page instead, omitting the anchor specification.
If I disable Senna.js with the relative data attribute, I can reach correctly my anchor instead:
<a data-senna-off="true" href="http://localhost:8080/en/web/my_site/my_other_page#my_anchor">
    my_other_page#my_anchor
</a>

Is there a way to avoid the senna.js behaviour on the first link, without adding the data-attribute?
I need a workaround because this kind of links are added by editors who don't work with source code so the addition of data-attribute is not a doable.

I was wondering if maybe this is doable inside my theme main.js through something like the following:
  Liferay.on('SPAReady', function(){
Liferay.SPA.app.on('beforeNavigate',
  function(event) {
    // Prevent default senna behaviour and
    // land me to the correct link#anchor...
  });
});


Is that approach correct? If not what solution could be used?
Thank you.
thumbnail
Juan Gonzalez, modifié il y a 7 années.

RE: Link with anchor: senna.js drops the anchor (Réponse)

Liferay Legend Publications: 3089 Date d'inscription: 28/10/08 Publications récentes
Hi Alessandro.

Seems it's fixed in master branch by this LPS: https://issues.liferay.com/browse/LPS-71199.

Take a look at git to search that LPS and find how to fix it (check for senna 2.1.4 changes).
thumbnail
Alessandro Candini, modifié il y a 7 années.

RE: Link with anchor: senna.js drops the anchor

Regular Member Publications: 130 Date d'inscription: 17/10/15 Publications récentes
Muchas gracias Juan!
Upgrading my Liferay 7 DXP with Fix Pack 13 fixed the issue: now I have senna 2.1.4 and no more anchors problems.
Thanks again!