Broadcast height to parents - useful when storybook is inside an iframe #84
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a script that listens for "requestHeight" messages, and replies with the document's height.
This was done because some pages on the brand guidelines site currently have a lot of empty space on the bottom, for example:
Brand guidelines page - autocomplete component
This is because we're setting the iframe's height to 6000 pixels by default. Why do we do this? The reason is: iframes don't stretch to their children's height. And there's no way currently to know the iframe's height (if we try to access the iframe's document, we get a CORS error). With the script introduced in this PR, it is now possible to know the iframe's height.
How to test locally
Run the logos brand guidelines site locally. And then:
storybookUrl="https://63e4f71c39dc65c5c703c1e8-bzapfmeede.chromatic.com"
Finally, we can check out the page with that component: the height of the iframe should be okay, without any scroll bars and without large empty space on the bottom of the page.