Skip to content

Commit

Permalink
Fix collapsing html email preview (#351)
Browse files Browse the repository at this point in the history
In some cases, the css of an email may cause the
`document.body.clientHeight` to report 0, which collapses the email
preview iframe. Using `contentWindow.outerHeight` seems to work around
this issue.
  • Loading branch information
RobinClowers authored and paulcsmith committed Feb 27, 2018
1 parent d223fce commit 6427374
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/bamboo/plug/sent_email_viewer/index.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@
<p class="email-detail-body">
<script>
function adjustFrameHeight(iframe) {
var body = iframe.contentWindow.document.body;
iframe.style.height = (body.scrollHeight + body.offsetHeight - body.clientHeight) + "px";
var contentWindow = iframe.contentWindow;
iframe.style.height = (contentWindow.outerHeight) + "px";
}
</script>
<iframe onload="adjustFrameHeight(this)" src="<%= "#{@base_path}/#{Bamboo.SentEmail.get_id(@selected_email)}/html" %>"></iframe>
Expand Down

0 comments on commit 6427374

Please sign in to comment.