Embed Improvements: Add auto-scroll support back, reduce CLS, remove loader for Routing Form embed (#4819)

* Add back auto-scroll fix with proper check of visibilith

* Do improvement in CLS and dont show "Loading" text

* Improve experience with routing forms embed

Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
Hariom BalharaandAlex van Andel authored and GitHub committed 2022-10-14 10:10:54 +00:00
1 parent 88cad2e15f
commit 8583d9b2e6
7 files changed
+63 -22

No files matched your search

+9 -2
View File
@@ -35,6 +35,12 @@ function toRunBeforeReactOnClient() {
const namespace = url.searchParams.get("embed");
return namespace;
};
window.isPageOptimizedForEmbed = () => {
// Those pages are considered optimized, which know at backend that they are rendering for embed.
// Such pages can be shown straightaway without a loader for a better embed experience
return location.pathname.includes("forms/");
};
}
class MyDocument extends Document<Props> {
@@ -76,7 +82,6 @@ class MyDocument extends Document<Props> {
/>
</Head>
{/* Keep the embed hidden till parent initializes and gives it the appropriate styles */}
<body className="dark:bg-darkgray-50 desktop-transparent bg-gray-100">
<Main />
<NextScript />
@@ -86,7 +91,9 @@ class MyDocument extends Document<Props> {
dangerouslySetInnerHTML={{
__html: `
if (isEmbed()) {
document.body.style.display="none";
if(!isPageOptimizedForEmbed()) {
document.body.style.display="none";
}
document.body.style.background="transparent";
}`,
}}