Closed Antimated closed 6 months ago
Hi @Antimated
I can’t seem to reproduce. When the preview tab is opened with this template:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Boilerplate</title>
</head>
<body>
<h1></h1>
{{ order.reference }}
</body>
</html>
I get this:
There is no CSS included. Let me know if I missed something.
Were any plugins installed in your tests or are you starting from a bare project?
EDIT: I have no idea why but for some reason the issue seems to be gone. Not sure if something like the vite plugin interfered or not, but last week I had this issue persisting. Now opening the project and previewing the test mails gives me no injected cp resources anymore... Weird. Or could some kind of caching be the culprit?
Now I have it again... I have no idea why it displays now. I did add &number={reference}
to the end of the url though. but after removing that iI still have cpresource urls...
Were any plugins installed in your tests or are you starting from a bare project?
Pretty bare project. I will play around with using different twig/plugin functions to see if I can trigger it. Can you share your template easily?
Hmmm not really, it's a private project for the company I work for. I'll see what I can do.
We render the template with:
https://github.com/craftcms/commerce/blob/develop/src/controllers/EmailPreviewController.php#L71
View::TEMPLATE_MODE_SITE
so it shouldn't include backed resources.
Could you be viewing the preview error response?
https://github.com/craftcms/commerce/blob/develop/src/controllers/EmailPreviewController.php#L79
https://github.com/craftcms/commerce/blob/develop/src/templates/settings/emails/_previewError.twig
It would include the CP resources since we render it from the CP and don't pass View::TEMPLATE_MODE_SITE
.
Doesn't look like it shows an error as far as I can see. Just added a quick log statement before line 71 and that displays in the logging software we use (we use Ray).
This is the url we use http://jules-2024.test/index.php?p=craft%2Factions%2Fcommerce%2Femail-preview%2Frender&site=julesNl&emailId=1
@Antimated any luck figuring this one out? I can't seem to reproduce it.
Could you email composer.json composer.lock DB backup modules/ folder templates/ folder config/ folder
in a zip to support@craftcms.com and reference this issue, and we can see if reproduce with your project.
@Antimated any luck figuring this one out? I can't seem to reproduce it.
Could you email composer.json composer.lock DB backup modules/ folder templates/ folder config/ folder
in a zip to support@craftcms.com and reference this issue, and we can see if reproduce with your project.
Just sent the e-mail. Let me know if you guys received it on your end!
The mail subject is: Files for issue: [4.x]: Email previews load CP resources which overwrite mail CSS.
.
If it doesn't go through I might have to send it again using something like wetransfer.
EDIT: Had to send it via Wetransfer, wouldn't let me send it directly from my work e-mail for some reason!
I believe this issue was resolved in support and was due to custom module code.
What happened?
Description
Previewing e-mails made in
System settings > Emails
have unexpected output. Because multiple CP resource stylesheets are loaded in (which probably shouldn't happen) some CSS gets overwritten.Here you can see that the anchor rule gets overwritten by
tailwind_reset.css
and then by_main.scss
which both are CP resourcesSteps to reproduce
System settings > Emails
Expected behavior
No CP js or css should be loaded here. Especially the CSS because it overwrites certain styles. If any css modifying happens in the injected js files, it could also overwrite css that way
Actual behavior
CP resource assets (js and css) are loaded
Craft CMS version
4.8.5
Craft Commerce version
4.5.2
PHP version
8.1.5
Operating system and version
Darwin 22.2.0
Database type and version
MySQL 5.7.34
Image driver and version
GD 8.1.5
Installed plugins and versions