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

Small Embed Fixes #7513

Merged
merged 6 commits into from
Mar 4, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/e2e-embed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ jobs:
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: test-results-core
name: test-results-embed-core
path: packages/embeds/embed-core/playwright/results

- name: Upload embed-react results
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: test-results-react
name: test-results-embed-react
path: packages/embeds/embed-react/playwright/results
4 changes: 2 additions & 2 deletions packages/embeds/embed-core/src/Inline/inlineHtml.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const html = `<div id="wrapper" style="top:50%; left:50%" class="absolute z-highest">
<div style="transform:translate(-50%,-50%)" class="loader border-brand dark:border-darkmodebrand">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style="top:50%; left:50%" and style="transform:translate(-50%,-50%)" has to be on same element for center positioning to work correctly.

const html = `<div id="wrapper" style="top:50%; left:50%;transform:translate(-50%,-50%)" class="absolute z-highest">
<div class="loader border-brand dark:border-darkmodebrand">
<span class="loader-inner bg-brand dark:bg-darkmodebrand"></span>
</div>
<div id="error" style="transform:translate(-50%,-50%)" class="hidden">
Expand Down
11 changes: 9 additions & 2 deletions packages/embeds/embed-core/src/embed-iframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,15 @@ function keepParentInformedAboutDimensionChanges() {
throw new Error("Main element should be an HTMLElement");
}

const contentHeight = mainElement.offsetHeight;
const contentWidth = mainElement.offsetWidth;
const mainElementStyles = getComputedStyle(mainElement);
const contentHeight =
Copy link
Member Author

@hariombalhara hariombalhara Mar 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

offset doesn't include margin. So consider that as success page main element has margins.
Ideally, main element shouldn't have margins in embed, but this fix is needed anyway so that a scroll isn't shown in embed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh the joys :')

mainElement.offsetHeight +
parseInt(mainElementStyles.marginTop) +
parseInt(mainElementStyles.marginBottom);
const contentWidth =
mainElement.offsetWidth +
parseInt(mainElementStyles.marginLeft) +
parseInt(mainElementStyles.marginRight);

// During first render let iframe tell parent that how much is the expected height to avoid scroll.
// Parent would set the same value as the height of iframe which would prevent scroll.
Expand Down