Project

General

Profile

Actions

Bug #82179

closed

FormEngine triggers link explanation when new links are created, when it shouldn't

Added by Johannes Schlier over 7 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Must have
Category:
Backend JavaScript
Target version:
Start date:
2017-08-23
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
8
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

If there are links on a backend form they are correctly initialised by FormEngine.js with the following code on lines 1005-1022:

    FormEngine.initializeInputLinkToggle = function() {
        var toggleClass = '.t3js-form-field-inputlink-explanation-toggle',
            inputFieldClass = '.t3js-form-field-inputlink-input',
            explanationClass = '.t3js-form-field-inputlink-explanation';

        // if empty, show input field
        $(explanationClass).filter(function () {
            return !$.trim($(this).val());
        }).each(function () {
            var $group = $(this).closest('.t3js-form-field-inputlink'),
                $inputField = $group.find(inputFieldClass),
                $explanationField = $group.find(explanationClass),
                explanationShown;
            explanationShown = !$explanationField.hasClass('hidden');
            $explanationField.toggleClass('hidden', explanationShown);
            $inputField.toggleClass('hidden', !explanationShown);
            $group.find('.form-control-clearable button.close').toggleClass('hidden', !explanationShown)
        });

This works correctly the first time, but if a new link is created, as an IRRE element for example, the same code is executed again.
This means that the line

            explanationShown = !$explanationField.hasClass('hidden');

gives a different result and all link fields that are empty (or not empty, but not yet saved), are triggered again, even though they shouldn't. This leads to the empty explanation field being shown, which cannot be triggered to the input field again.
Creating another link after this triggers them again with the same result as the first time - with the input field shown, not the explanation field. And so on ...

Actions

Also available in: Atom PDF