mjml icon indicating copy to clipboard operation
mjml copied to clipboard

mj-column: Incorrect width calculation in mobile view when fixed width in pixel is specified

Open surajpoddar16 opened this issue 2 years ago • 6 comments

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 Screenshot 2022-06-28 at 8 01 13 PM

surajpoddar16 avatar Jun 28 '22 14:06 surajpoddar16

I can pick this up, if this is not expected.

surajpoddar16 avatar Jun 28 '22 14:06 surajpoddar16

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

iRyusa avatar Jun 28 '22 15:06 iRyusa

Above the mobile view breakpoint, the fixed pixel value is respected, the problem occurs below the mobile breakpoint.

surajpoddar16 avatar Jun 29 '22 17:06 surajpoddar16

Yup because it's only on the mobile width that you have this issue. You can open a PR on this if you want

iRyusa avatar Jul 04 '22 11:07 iRyusa

Why was #2507 closed?

PumpedSardines avatar Feb 10 '23 16:02 PumpedSardines

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.

sneko avatar Feb 23 '23 19:02 sneko