Summary / Description
In the TYPO3 backend Page module, paste_reference can generate an invalid page ID when the language view is set to "All languages" or a translated language such as "English".
The JavaScript currently reads the page ID via a generic selector:
document.querySelector('[data-page]')
In TYPO3 v13 language comparison views, the first matching element can be a TYPO3 localization action button where data-page contains the page title/slug,instead of the numeric page ID.
This causes parseInt(..., 10) to return NaN, which later leads to the error:
Error generating unique ID: Error: Invalid page ID for unique ID generation
Version
- ehaerer/paste-reference: 4.0.5
- TYPO3 CMS: 13.4.32
Steps to reproduce
- Create or open a page that has content elements and at least one additional backend language, for example English.
- Open the TYPO3 backend Page module for that page.
- Switch the language display to either:
- All languages
- or a translated language, for example English
- Open the browser developer console.
Expected behaviour
The paste reference JavaScript should resolve the numeric page ID of the current page and generate stable unique IDs for paste targets without console errors.
Example expected ID format:
page_290863-colpos_0-tt_content_0
Actual behavior
The JavaScript sometimes reads the wrong data-page attribute.
In TYPO3 v13 language comparison views, the first [data-page] element can be a localization button like this:
<a class="btn btn-default btn-sm t3js-localize"
data-page="testseite003"
data-page-id="290863">
Because data-page="testseite003" is not numeric, the generated page ID becomes NaN.
The browser console then shows:
Error generating unique ID: Error: Invalid page ID for unique ID generation
at Draggable.getUniqueId (...)
at paste-reference.js (...)
The issue does not occur in the default language view in our setup because the first [data-page] element there is the actual page content container with a numeric page ID.
Additional
Possible fix
The selector should be scoped to the TYPO3 page content element instead of using the first arbitrary [data-page] element in the document.
For example, replace:
document.querySelector('[data-page]')
with:
document.querySelector('.t3js-page-ce[data-page]')
Affected locations:
This avoids selecting TYPO3 backend action buttons or other unrelated elements that also use a data-page attribute.
Miscellaneous
Observed console error:
Error generating unique ID: Error: Invalid page ID for unique ID generation
at Draggable.getUniqueId (...)
at paste-reference.js (...)
at NodeList.forEach (<anonymous>)
at PasteReference.activatePasteIcons (...)
Summary / Description
In the TYPO3 backend Page module,
paste_referencecan generate an invalid page ID when the language view is set to "All languages" or a translated language such as "English".The JavaScript currently reads the page ID via a generic selector:
In TYPO3 v13 language comparison views, the first matching element can be a TYPO3 localization action button where
data-pagecontains the page title/slug,instead of the numeric page ID.This causes
parseInt(..., 10)to returnNaN, which later leads to the error:Error generating unique ID: Error: Invalid page ID for unique ID generation
Version
Steps to reproduce
Expected behaviour
The paste reference JavaScript should resolve the numeric page ID of the current page and generate stable unique IDs for paste targets without console errors.
Example expected ID format:
page_290863-colpos_0-tt_content_0
Actual behavior
The JavaScript sometimes reads the wrong data-page attribute.
In TYPO3 v13 language comparison views, the first
[data-page]element can be a localization button like this:Because
data-page="testseite003"is not numeric, the generated page ID becomesNaN.The browser console then shows:
The issue does not occur in the default language view in our setup because the first
[data-page]element there is the actual page content container with a numeric page ID.Additional
Possible fix
The selector should be scoped to the TYPO3 page content element instead of using the first arbitrary
[data-page]element in the document.For example, replace:
document.querySelector('[data-page]')with:
document.querySelector('.t3js-page-ce[data-page]')Affected locations:
This avoids selecting TYPO3 backend action buttons or other unrelated elements that also use a data-page attribute.
Miscellaneous
Observed console error: