EDIT: I shouldn't have asked this question. See my answer below.
I have my own custom template on Joomla 4.0.6 with a simple scroll-to-top function.
If I open edit an article on the front end, however, and select any function that results in a pop-up modal - e.g. media select in either Content > CMS Content or in the 'Images and Links' tab I get an error via the browser inspector saying:
"Uncaught TypeError: scrollToTopBtn is null"
I understand partly why this is happening as the modal is in an iframe.
When the modal is opened, the class modal-open
is added to the body
tag.
So, I thought I'd wrap the JS in this:
if (!document.querySelector('.modal-open')) {
//my scroll-to-top script here
}
But it doesn't work. Any suggestions gratefully appreciated.
It would also be great if someone could add 'Joomla-4x' to the Tags below.