Bug #96731
closedTYPO3 11.5 LTS - SPAM protected email links will not work if there is a child element clickable in the link.
0%
Description
I have an email link according to the following structure:
<a class="mail-button" href="#" data-mailto-token="ocknvq,hqqBdct0vnf" data-mailto-vector="1">
<span class="icon-mail"></span>
</a>
It is a simple letter symbol with some padding.
If I click on the padding area, the JavaScript from the default_frontend.js is executed correctly.
But if I click on the letter-symbol, i.e. the span-tag, the JavaScript gets as "evt.target" not the a-tag, but the span-tag, which has no data-attributes and thus the missing "value" leads to a JavaScript error.
/typo3/sysext/frontend/Resources/Public/JavaScript/default_frontend.js
Extract from this file, line 92-100
Array.from(mailtoElements).forEach(function(element) {
element.addEventListener('click', function(evt) {
evt.preventDefault();
var dataset= evt.target.dataset; // evt can be childNode, if a-tag has child-elements
var value = dataset.mailtoToken;
var offset = parseInt(dataset.mailtoVector, 10) * -1;
document.location.href = decryptString(value, offset);
});
});
I have now solved the problem using CSS. However, it would be nicer not to let the problem arise directly in the JavaScript in the first place.
My current bugfix:
a.mail-button span {
pointer-events: none; # disables click-event on child span-tag
}
Updated by Georg Ringer almost 3 years ago
- Related to Bug #96668: "Enlarge on Click" does not work anymore added
Updated by Georg Ringer almost 3 years ago
- Status changed from Accepted to Needs Feedback
this sounds like a duplicate of #96668.
Can you test if the already merged change https://review.typo3.org/c/Packages/TYPO3.CMS/+/73194/3/typo3/sysext/frontend/Resources/Public/JavaScript/default_frontend.js works for you?
Updated by Markus Eckert almost 3 years ago
Hi Georg, yes this solves the problem for me. Thanks a lot for fast help!
Updated by Georg Ringer almost 3 years ago
- Status changed from Needs Feedback to Closed
thanks for the fast feedback, issue closed as duplicate