-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Remove margin from sandbox iframe to fix size calculation #1688
Conversation
…count for margins
980b2e0
to
8074a41
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this calculates correctly. I'm not sure the original does either, I did notice some cut-off even on twitter embeds...
This is how a twitter embed should look:
but changing to use scrollWidth and scrollHeight results in this:
The problem here is that it appears that the extra space can be clicked in to edit the caption, but it can't be. You have to click in a very specific area that is not visually delimited, as it clearly is in the first picture (the end of the tweet is the end of the embedded html, below it immediately is the caption).
The list of embeds we've been using to test is:
Short tweet:
https://twitter.com/notnownikki/status/876229494465581056
Tall tweet:
https://twitter.com/PattyJenks/status/874034832430424065
Youtube:
https://www.youtube.com/watch?v=PfKUdmTq2MI
Photo:
https://cloudup.com/cl3Oq5MU8Rm
Long tumblr post:
http://doctorwho.tumblr.com/post/162052108791
Perhaps we can add the margin sizes? Or in the document we create for the iframe, reset all margins?
In an alternate implementation of this behavior, we'd switched from |
@aduth @notnownikki Using |
A couple other fixes related to the sandbox component:
|
@notnownikki how's this look for you? |
Looking better, but seems to have broken photo embeds from cloudup. The long tweet, short tweet, youtube, and long tumblr embed are all pretty much pixel perfect now, but the test embed from cloudup ( https://cloudup.com/cl3Oq5MU8Rm ) doesn't show anything. |
Ah, I think I see the problem with photo embeds. Because some sites return the full size photo for a thumbnail, we set the width of photos to 100%, so they just fill the block and get the right height automatically. But, this change adds style, which sets the width and height to whatever's in the state, which by default is 0. That means the image ends up 0px wide and 0px tall, and gets hidden completely. |
Ok, I've just tested with removing the
... and things look good for all the embeds and the Custom HTML block. |
@notnownikki Very strange. I don't see why using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works with everything I threw at it, including the custom html!
@notnownikki is there a reason why |
Also, I found a core bug with the oEmbed proxy endpoint in core where the |
@westonruter Looking at #1658, yeah, we should zero the margins. We generate the HTML document for the iframe in |
Cool, I added it to |
Works great with everything I threw at it again! Happy to see this 🚢 |
487ea4d
to
a394e9a
Compare
The sandboxed
iframe
was not getting resized enough to account for the margins of the body inside the iframed window. The result, as I'm working on adding sandboxing to the Custom HTML block (#1625), is the content being cut off:With the fix, it looks like:
Amends #1392