Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The whole button area is not clickable #2565

Open
fernamp opened this issue Oct 28, 2022 · 7 comments
Open

The whole button area is not clickable #2565

fernamp opened this issue Oct 28, 2022 · 7 comments

Comments

@fernamp
Copy link

fernamp commented Oct 28, 2022

The mj-button does not work as expected in MSO PC desktop because it has specific instructions that produce the problem.

To Reproduce
Steps to reproduce the behavior:

  1. use the usual:
    <mj-button href="www.google.com" border="1px solid red">Unmodified button</mj-button>

  2. The HTML produced is this one:

<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:separate;line-height:100%;">
    <tr>
        <td align="center" bgcolor="#414141" role="presentation" style="border:1px solid red; border-radius:3px; cursor:auto; background:#414141; mso-padding-alt:10px 25px;" valign="middle">
            <a href="www.google.com" style="display:inline-block; background:#414141; color:#ffffff; font-family:Ubuntu, Helvetica, Arial, sans-serif; font-size:13px; font-weight:normal; line-height:120%; margin:0; text-decoration:none; text-transform:none; padding:10px 25px; mso-padding-alt:0px; border-radius:3px;" target="_blank"> Unmodified button </a>
        </td>
    </tr>
</table>

Expected behavior
This HTML:

<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:separate; line-height:100%;">
    <tr>
        <td align="center" bgcolor="#414141" role="presentation" style="border:1px solid red; border-radius:3px; cursor:auto; background:#414141;" valign="middle">
            <a href="www.google.com" style="display:inline-block; background:#414141; color:#ffffff; font-family:Ubuntu, Helvetica, Arial, sans-serif; font-size:13px; font-weight:normal; line-height:120%; margin:0; text-decoration:none; text-transform:none; padding:10px 25px; border-radius:3px; border: 1px solid #414141;" target="_blank"> Modified button </a>
        </td>
    </tr>
</table>

In MSO, <a> is an inline but UNMODIFIABLE element (it can't become a block, nor an inline-block), unless you trick MSO into think that the <a> is "something" cause it has a border, triggering the use of the display declaration and therefore, the use of the padding (so removing the tool that provides the inner spacing of the button using mso-padding-alt: 0px; is kind of weird (taking into account that adding padding to the <a> in MSO has no real effect).

The previous code make the whole button clickable in MSO.

Screenshots
Unmodified MJML button HTML:
198571169-29e2a601-2a90-4c6e-abad-3720978f19af

Modified MJML button HTML:
198571696-79a1ad28-131d-4bc0-9e22-a92169c4cd97

Is this something MJML team can take? Or should I make a branch?

@iRyusa
Copy link
Member

iRyusa commented Oct 31, 2022

Damn that would be such a nice fix to have if it have 0 side effects ! Great finding !

How does it work with transparent buttons ? You put a 1px solid transparent on a tag ?
Can we try to have a compatibility (emailonacid/litmus) test with fixed width button, multi lines button, and button with img inside it ?

We need to be sure it won't break anything else in other desktop clients.

@fernamp
Copy link
Author

fernamp commented Nov 1, 2022

I'll be onto it later this week. I will return to post info as soon as I have some data and tests from EOA and Litmus.
Thanks for the testing ideas btw!

@robertmylne
Copy link

This issue has been solved here by Maizzle: https://maizzle.com/docs/examples/buttons

<a
  href="https://maizzle.com/"
  class="inline-block py-4 px-6 text-sm leading-none font-semibold rounded [text-decoration:none] text-white bg-indigo-500 hover:bg-indigo-600">
  <!--[if mso]><i style="letter-spacing: 27px; mso-font-width: -100%; mso-text-raise: 26pt;">&nbsp;</i><![endif]-->
    <span style="mso-text-raise: 13pt;">Read more</span>
  <!--[if mso]><i style="letter-spacing: 27px; mso-font-width: -100%;">&nbsp;</i><![endif]-->
</a>

@iRyusa
Copy link
Member

iRyusa commented Nov 13, 2022 via email

@fernamp
Copy link
Author

fernamp commented Nov 18, 2022

OK, I did some tests and changes to the mjml-button\src\index.js file and that solves the clickable area.

  • First, removed the mso-padding-alt from the TD.
  • removed the mso-padding-alt from the Ahref ("content") and added:
    border: this.getAttribute('background-color') + ' 1px solid', before the border-radius declaration, in the "content" area.

image

The colour of the "border" should be coordinated with the colour of the TD's background.

Here the MJML with the test:

image

and here the resulting HTML:

image

Results in EOA and Litmus show the button working everywhere.

This is from MSO 2019:

image

I have to check with my company if I can share the links.

Or contact me directly to share them (I'll try to do it from my side anyway).

I'll check if the Maizzle implementation is usable/implementable in MJML.

@iRyusa
Copy link
Member

iRyusa commented Nov 23, 2022

Looks good then if you can open a PR about this ? I think it should just handle the case where user wants another border color on this one 👍

@iRyusa
Copy link
Member

iRyusa commented Dec 13, 2023

Sorry to come back very late about this, but can we test multi line button with this technique ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants