Project

General

Profile

Actions

Bug #96731

closed

TYPO3 11.5 LTS - SPAM protected email links will not work if there is a child element clickable in the link.

Added by Markus Eckert almost 3 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Frontend
Target version:
Start date:
2022-02-02
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
7.4
Tags:
emailprotection
Complexity:
easy
Is Regression:
Sprint Focus:

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
    }

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #96668: "Enlarge on Click" does not work anymoreClosed2022-01-28

Actions
Actions #1

Updated by Markus Eckert almost 3 years ago

  • Description updated (diff)
Actions #2

Updated by Markus Eckert almost 3 years ago

  • Description updated (diff)
Actions #3

Updated by Markus Eckert almost 3 years ago

  • Description updated (diff)
Actions #4

Updated by Georg Ringer almost 3 years ago

  • Status changed from New to Accepted
Actions #5

Updated by Georg Ringer almost 3 years ago

  • Related to Bug #96668: "Enlarge on Click" does not work anymore added
Actions #6

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?

Actions #7

Updated by Markus Eckert almost 3 years ago

Hi Georg, yes this solves the problem for me. Thanks a lot for fast help!

Actions #8

Updated by Georg Ringer almost 3 years ago

  • Status changed from Needs Feedback to Closed

thanks for the fast feedback, issue closed as duplicate

Actions

Also available in: Atom PDF