Fórum

Link with anchor: senna.js drops the anchor

thumbnail
Alessandro Candini, modificado 7 Anos atrás.

Link with anchor: senna.js drops the anchor

Regular Member Postagens: 130 Data de Entrada: 17/10/15 Postagens Recentes
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, modificado 7 Anos atrás.

RE: Link with anchor: senna.js drops the anchor (Resposta)

Liferay Legend Postagens: 3089 Data de Entrada: 28/10/08 Postagens Recentes
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, modificado 7 Anos atrás.

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

Regular Member Postagens: 130 Data de Entrada: 17/10/15 Postagens Recentes
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!