mjml
mjml copied to clipboard
mj-column: Incorrect width calculation in mobile view when fixed width in pixel is specified
Describe the bug If a fixed width is specified in mj-column, the column gets rendered correctly in desktop view, but in mobile view the formula used for width percentage seems wrong
https://github.com/mjmlio/mjml/blob/master/packages/mjml-column/src/index.js#L141
Expected behavior
return ${parsedWidth * 100 / parseInt(containerWidth, 10)}%
MJML environment (please complete the following information):
- OS: MacOS
- MJML Version 4.5.1, 4.12.0
- MJML tool used npm package
Email sending environment(for rendering issues):
- Platform used to send the email [e.g Putsmail]
Affected email clients (for rendering issues):
- Email Client [e.g Gmail]
- OS: [e.g. Windows]
- Browser [e.g. Google Chrome]
Screenshots
I can pick this up, if this is not expected.
Yup most likely missing a *100 and rounding 🤔
We expect column to be defined in percentage in mj-group as stated in the doc as we convert them back in % anyway:
Column inside a group must have a width in percentage, not in pixel
Above the mobile view breakpoint, the fixed pixel value is respected, the problem occurs below the mobile breakpoint.
Yup because it's only on the mobile width that you have this issue. You can open a PR on this if you want
Why was #2507 closed?
I can confirm this issue.
I switched to percentage for columns as mentioned above. But still, I do think this could be solved because having a weird tiny percentage for no reason makes no sense. And if a column requires a %, the compilation should fail when using pixels.