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 3 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
8 changes: 2 additions & 6 deletions apps/web/pages/[user].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,8 @@ export default function User(props: inferSSRProps<typeof getServerSideProps> & E
/>
<CustomBranding lightVal={profile.brandColor} darkVal={profile.darkBrandColor} />

<div
className={classNames(
shouldAlignCentrally ? "mx-auto" : "",
isEmbed ? "max-w-3xl" : "",
"dark:bg-darkgray-50"
)}>
<div className={classNames(shouldAlignCentrally ? "mx-auto" : "", isEmbed ? "max-w-3xl" : "")}>
{/* There should only be two places to add dark theme - Either at body or (at main tag or an element with .main class )*/}
<main
className={classNames(
shouldAlignCentrally ? "mx-auto" : "",
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