From 473665fc60ae7fca95eea33ff136ab4fdfde41d7 Mon Sep 17 00:00:00 2001 From: sharath kannan Date: Fri, 3 Jan 2025 23:31:55 +0530 Subject: [PATCH 01/13] table header bug fix --- libs/blocks/table/table.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/blocks/table/table.js b/libs/blocks/table/table.js index ab0d1ce3da..6532ad37d4 100644 --- a/libs/blocks/table/table.js +++ b/libs/blocks/table/table.js @@ -149,7 +149,7 @@ function handleAddOnContent(table) { el?.insertAdjacentElement(order === 'before' ? 'beforebegin' : 'afterend', tag); }); }); - setTimeout(() => handleEqualHeight(table, '.row-heading'), 0); + setTimeout(() => handleEqualHeight(table, '.row-heading'), 70); } function handleHighlight(table) { From d7678557087bf53dac3356a5f312c5f35460af5c Mon Sep 17 00:00:00 2001 From: sharath kannan Date: Fri, 3 Jan 2025 23:51:47 +0530 Subject: [PATCH 02/13] resolved evet added --- libs/blocks/table/table.js | 43 +++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/libs/blocks/table/table.js b/libs/blocks/table/table.js index 6532ad37d4..0420954f1e 100644 --- a/libs/blocks/table/table.js +++ b/libs/blocks/table/table.js @@ -25,6 +25,25 @@ function isStickyHeader(el) { || (el.classList.contains('sticky-tablet-up') && defineDeviceByScreenSize() !== 'MOBILE' && !isMobileLandscape()); } +function handleEqualHeight(table, tag) { + const height = []; + const element = table.querySelector(tag); + const columns = [...element.children]; + columns.forEach(({ children }) => { + [...children].forEach((row, i) => { + row.style.height = 'auto'; + if (!height[i] || row.offsetHeight > height[i]) { + height[i] = row.offsetHeight; + } + }); + }); + columns.forEach(({ children }) => { + [...children].forEach((row, i) => { + row.style.height = height[i] > 0 ? `${height[i]}px` : 'auto'; + }); + }); +} + function handleHeading(table, headingCols) { const isPriceBottom = table.classList.contains('pricing-bottom'); headingCols.forEach((col, i) => { @@ -43,6 +62,11 @@ function handleHeading(table, headingCols) { } elements[textStartIndex]?.classList.add('tracking-header'); const pricingElem = elements[textStartIndex + 1]; + const span = pricingElem.querySelector('[is=inline-price]'); + span.addEventListener('mas:resolved', () => { + console.log('resolved event'); + handleEqualHeight(table, '.row-heading'); + }); const bodyElem = elements[textStartIndex + 2]; if (pricingElem) { @@ -98,25 +122,6 @@ function handleHeading(table, headingCols) { }); } -function handleEqualHeight(table, tag) { - const height = []; - const element = table.querySelector(tag); - const columns = [...element.children]; - columns.forEach(({ children }) => { - [...children].forEach((row, i) => { - row.style.height = 'auto'; - if (!height[i] || row.offsetHeight > height[i]) { - height[i] = row.offsetHeight; - } - }); - }); - columns.forEach(({ children }) => { - [...children].forEach((row, i) => { - row.style.height = height[i] > 0 ? `${height[i]}px` : 'auto'; - }); - }); -} - function handleAddOnContent(table) { const addOnKey = 'ADDON'; const addOns = [...table.querySelectorAll('.section-row-title')] From acb9580377f5984a9b459da66378720405a8eba4 Mon Sep 17 00:00:00 2001 From: sharath kannan Date: Mon, 6 Jan 2025 15:53:05 +0530 Subject: [PATCH 03/13] once settled added --- libs/blocks/table/table.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libs/blocks/table/table.js b/libs/blocks/table/table.js index 0420954f1e..f9305fc209 100644 --- a/libs/blocks/table/table.js +++ b/libs/blocks/table/table.js @@ -63,6 +63,9 @@ function handleHeading(table, headingCols) { elements[textStartIndex]?.classList.add('tracking-header'); const pricingElem = elements[textStartIndex + 1]; const span = pricingElem.querySelector('[is=inline-price]'); + span.onceSettled().then(() => { + console.log('settled'); + }); span.addEventListener('mas:resolved', () => { console.log('resolved event'); handleEqualHeight(table, '.row-heading'); From b6147ba83212931b80d61575d46e580ddbe99689 Mon Sep 17 00:00:00 2001 From: sharath kannan Date: Tue, 7 Jan 2025 12:34:12 +0530 Subject: [PATCH 04/13] table heading height handling --- libs/blocks/table/table.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libs/blocks/table/table.js b/libs/blocks/table/table.js index f9305fc209..4e8cb26c3d 100644 --- a/libs/blocks/table/table.js +++ b/libs/blocks/table/table.js @@ -63,11 +63,7 @@ function handleHeading(table, headingCols) { elements[textStartIndex]?.classList.add('tracking-header'); const pricingElem = elements[textStartIndex + 1]; const span = pricingElem.querySelector('[is=inline-price]'); - span.onceSettled().then(() => { - console.log('settled'); - }); span.addEventListener('mas:resolved', () => { - console.log('resolved event'); handleEqualHeight(table, '.row-heading'); }); const bodyElem = elements[textStartIndex + 2]; From 2d6248b70f206a6ce431503b05f5422af6b10425 Mon Sep 17 00:00:00 2001 From: sharath kannan Date: Tue, 7 Jan 2025 16:59:26 +0530 Subject: [PATCH 05/13] setInterval approach --- libs/blocks/table/table.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libs/blocks/table/table.js b/libs/blocks/table/table.js index 4e8cb26c3d..95f96a3dab 100644 --- a/libs/blocks/table/table.js +++ b/libs/blocks/table/table.js @@ -62,10 +62,14 @@ function handleHeading(table, headingCols) { } elements[textStartIndex]?.classList.add('tracking-header'); const pricingElem = elements[textStartIndex + 1]; - const span = pricingElem.querySelector('[is=inline-price]'); - span.addEventListener('mas:resolved', () => { - handleEqualHeight(table, '.row-heading'); - }); + const interval = setInterval(() => { + const span = table.querySelector('[is=inline-price]'); + if (span.classList.contains('placeholder-resolved')) { + handleEqualHeight(table, '.row-heading'); + clearInterval(interval); + } + }, 100); + debounce(() => { clearInterval(interval); }, 2000); const bodyElem = elements[textStartIndex + 2]; if (pricingElem) { @@ -153,7 +157,7 @@ function handleAddOnContent(table) { el?.insertAdjacentElement(order === 'before' ? 'beforebegin' : 'afterend', tag); }); }); - setTimeout(() => handleEqualHeight(table, '.row-heading'), 70); + setTimeout(() => handleEqualHeight(table, '.row-heading'), 0); } function handleHighlight(table) { From 57a4a0a72926b7a0406fdc430e3075ec802ff6cc Mon Sep 17 00:00:00 2001 From: sharath kannan Date: Tue, 7 Jan 2025 23:17:53 +0530 Subject: [PATCH 06/13] mas:resolved added to parent element --- libs/blocks/table/table.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/libs/blocks/table/table.js b/libs/blocks/table/table.js index 95f96a3dab..050f8e2beb 100644 --- a/libs/blocks/table/table.js +++ b/libs/blocks/table/table.js @@ -62,14 +62,7 @@ function handleHeading(table, headingCols) { } elements[textStartIndex]?.classList.add('tracking-header'); const pricingElem = elements[textStartIndex + 1]; - const interval = setInterval(() => { - const span = table.querySelector('[is=inline-price]'); - if (span.classList.contains('placeholder-resolved')) { - handleEqualHeight(table, '.row-heading'); - clearInterval(interval); - } - }, 100); - debounce(() => { clearInterval(interval); }, 2000); + table.addEventListener('mas:resolved', debounce(() => { handleEqualHeight(table, '.row-heading'); })); const bodyElem = elements[textStartIndex + 2]; if (pricingElem) { From 93c12268ca2d6b8a192c7a015b6ddf65b6d2eb3b Mon Sep 17 00:00:00 2001 From: sharath kannan Date: Tue, 7 Jan 2025 23:29:50 +0530 Subject: [PATCH 07/13] reverted unwanted changes --- libs/blocks/table/table.js | 42 +++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/libs/blocks/table/table.js b/libs/blocks/table/table.js index 050f8e2beb..171a19af9c 100644 --- a/libs/blocks/table/table.js +++ b/libs/blocks/table/table.js @@ -25,25 +25,6 @@ function isStickyHeader(el) { || (el.classList.contains('sticky-tablet-up') && defineDeviceByScreenSize() !== 'MOBILE' && !isMobileLandscape()); } -function handleEqualHeight(table, tag) { - const height = []; - const element = table.querySelector(tag); - const columns = [...element.children]; - columns.forEach(({ children }) => { - [...children].forEach((row, i) => { - row.style.height = 'auto'; - if (!height[i] || row.offsetHeight > height[i]) { - height[i] = row.offsetHeight; - } - }); - }); - columns.forEach(({ children }) => { - [...children].forEach((row, i) => { - row.style.height = height[i] > 0 ? `${height[i]}px` : 'auto'; - }); - }); -} - function handleHeading(table, headingCols) { const isPriceBottom = table.classList.contains('pricing-bottom'); headingCols.forEach((col, i) => { @@ -62,7 +43,6 @@ function handleHeading(table, headingCols) { } elements[textStartIndex]?.classList.add('tracking-header'); const pricingElem = elements[textStartIndex + 1]; - table.addEventListener('mas:resolved', debounce(() => { handleEqualHeight(table, '.row-heading'); })); const bodyElem = elements[textStartIndex + 2]; if (pricingElem) { @@ -118,6 +98,25 @@ function handleHeading(table, headingCols) { }); } +function handleEqualHeight(table, tag) { + const height = []; + const element = table.querySelector(tag); + const columns = [...element.children]; + columns.forEach(({ children }) => { + [...children].forEach((row, i) => { + row.style.height = 'auto'; + if (!height[i] || row.offsetHeight > height[i]) { + height[i] = row.offsetHeight; + } + }); + }); + columns.forEach(({ children }) => { + [...children].forEach((row, i) => { + row.style.height = height[i] > 0 ? `${height[i]}px` : 'auto'; + }); + }); +} + function handleAddOnContent(table) { const addOnKey = 'ADDON'; const addOns = [...table.querySelectorAll('.section-row-title')] @@ -150,7 +149,8 @@ function handleAddOnContent(table) { el?.insertAdjacentElement(order === 'before' ? 'beforebegin' : 'afterend', tag); }); }); - setTimeout(() => handleEqualHeight(table, '.row-heading'), 0); + // setTimeout(() => handleEqualHeight(table, '.row-heading'), 0); + table.addEventListener('mas:resolved', debounce(() => { handleEqualHeight(table, '.row-heading'); })); } function handleHighlight(table) { From 54c8def31f1546b9a4a0e6ebe907b980f46cfddf Mon Sep 17 00:00:00 2001 From: sharath kannan Date: Tue, 7 Jan 2025 23:30:27 +0530 Subject: [PATCH 08/13] reverted unwanted changes --- libs/blocks/table/table.js | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/blocks/table/table.js b/libs/blocks/table/table.js index 171a19af9c..47f5e35e5e 100644 --- a/libs/blocks/table/table.js +++ b/libs/blocks/table/table.js @@ -149,7 +149,6 @@ function handleAddOnContent(table) { el?.insertAdjacentElement(order === 'before' ? 'beforebegin' : 'afterend', tag); }); }); - // setTimeout(() => handleEqualHeight(table, '.row-heading'), 0); table.addEventListener('mas:resolved', debounce(() => { handleEqualHeight(table, '.row-heading'); })); } From b30602afe8fca113fd21cbfddcb01c2349397ff9 Mon Sep 17 00:00:00 2001 From: sharath kannan Date: Wed, 8 Jan 2025 16:06:36 +0530 Subject: [PATCH 09/13] height calculated for tables without pricing --- libs/blocks/table/table.js | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/blocks/table/table.js b/libs/blocks/table/table.js index 47f5e35e5e..2e6d2e8a9f 100644 --- a/libs/blocks/table/table.js +++ b/libs/blocks/table/table.js @@ -149,6 +149,7 @@ function handleAddOnContent(table) { el?.insertAdjacentElement(order === 'before' ? 'beforebegin' : 'afterend', tag); }); }); + setTimeout(() => handleEqualHeight(table, '.row-heading'), 0); table.addEventListener('mas:resolved', debounce(() => { handleEqualHeight(table, '.row-heading'); })); } From a1f8667a74157a666653ea263621146a6772f2f8 Mon Sep 17 00:00:00 2001 From: sharath kannan Date: Wed, 8 Jan 2025 23:06:40 +0530 Subject: [PATCH 10/13] added test cases --- libs/blocks/table/table.js | 2 +- test/blocks/table/mocks/body.html | 247 ++++++++++++++++++++++++++++++ test/blocks/table/table.test.js | 9 +- 3 files changed, 256 insertions(+), 2 deletions(-) diff --git a/libs/blocks/table/table.js b/libs/blocks/table/table.js index 2e6d2e8a9f..4c279ce07d 100644 --- a/libs/blocks/table/table.js +++ b/libs/blocks/table/table.js @@ -19,7 +19,7 @@ function defineDeviceByScreenSize() { return 'TABLET'; } -function isStickyHeader(el) { +export function isStickyHeader(el) { return el.classList.contains('sticky') || (el.classList.contains('sticky-desktop-up') && defineDeviceByScreenSize() === 'DESKTOP') || (el.classList.contains('sticky-tablet-up') && defineDeviceByScreenSize() !== 'MOBILE' && !isMobileLandscape()); diff --git a/test/blocks/table/mocks/body.html b/test/blocks/table/mocks/body.html index 6fb93feb80..a5e37a2b0b 100644 --- a/test/blocks/table/mocks/body.html +++ b/test/blocks/table/mocks/body.html @@ -247,6 +247,253 @@
+
+
+
+
+
Ee kj oyo kug it oi ooy o Bbibibi
+
e
+
+
+
+
+
Test1
+
+

Adobe Standard2

+

US$19.99/mo

+

Free trial

+

Buy now

+
+
+

Adobe Standard3

+

US$19.99/mo

+

Free trial

+

Buy now

+
+
+

Adobe Standard4

+

US$19.99/mo

+

Free trial

+

Buy now

+
+
+
+
+
+
+
+
+
+
+
+
+
E-signature core features signat core features
+
+
+
+
+
+
+
Right bold and Link
+
+
+
+
+
+
+
Sign agreements bold and Link
+
+
+
+
+
+
+
+

Track and manage agreements

+

+
+
+
+
+
+
+
+
+

Add a business stamp

+

+
+
+
+
+
+
+
+
+

Prepare forms

+

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Interact with PDFs
+
+
+
+
+
+
+
Collect signatures
+
+
+
+
+
+
+
Sign agreements
+
+
+
+
+
+
+
Track and manage agreements
+
+
+
+
+
+
+
Add a business stamp
+
+
+
+
+
+
+
Prepare forms
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
E-signature core features
+
+
+
+
+
+
+
Collect signatures
+
+
+
+
+
+
+
Sign agreements
+
+
+
+
+
+
+
+

Track and manage agreements

+

+
+
+
+
+
+
+
+
Add a business stamp
+
+
+
+
+
+
+
Prepare forms
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Interact with PDFs
+
+
+
+
+
+
+
Collect signatures
+
+
+
+
+
+
+
Sign agreements
+
+
+
+
+
+
+
Track and manage agreements
+
+
+
+
+
+
+
Add a business stamp
+
+
+
+
+
+
+
Prepare forms
+
+
+
+
+
+
-
-
-
-
-
Ee kj oyo kug it oi ooy o Bbibibi
-
e
-
-
-
-
-
Test1
-
-

Adobe Standard2

-

US$19.99/mo

-

Free trial

-

Buy now

-
-
-

Adobe Standard3

-

US$19.99/mo

-

Free trial

-

Buy now

-
-
-

Adobe Standard4

-

US$19.99/mo

-

Free trial

-

Buy now

-
-
-
-
-
-
-
-
-
-
-
-
-
E-signature core features signat core features
-
-
-
-
-
-
-
Right bold and Link
-
-
-
-
-
-
-
Sign agreements bold and Link
-
-
-
-
-
-
-
-

Track and manage agreements

-

-
-
-
-
-
-
-
-
-

Add a business stamp

-

-
-
-
-
-
-
-
-
-

Prepare forms

-

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Interact with PDFs
-
-
-
-
-
-
-
Collect signatures
-
-
-
-
-
-
-
Sign agreements
-
-
-
-
-
-
-
Track and manage agreements
-
-
-
-
-
-
-
Add a business stamp
-
-
-
-
-
-
-
Prepare forms
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
E-signature core features
-
-
-
-
-
-
-
Collect signatures
-
-
-
-
-
-
-
Sign agreements
-
-
-
-
-
-
-
-

Track and manage agreements

-

-
-
-
-
-
-
-
-
Add a business stamp
-
-
-
-
-
-
-
Prepare forms
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Interact with PDFs
-
-
-
-
-
-
-
Collect signatures
-
-
-
-
-
-
-
Sign agreements
-
-
-
-
-
-
-
Track and manage agreements
-
-
-
-
-
-
-
Add a business stamp
-
-
-
-
-
-
-
Prepare forms
-
-
-
-
-
-
+
+
+
+
+
Ee kj oyo kug it oi ooy o Bbibibi
+
e
+
+
+
+
+
Test1
+
+

Adobe Standard2

+

US$19.99/mo

+

Free trial

+

Buy now

+
+
+

Adobe Standard3

+

US$19.99/mo

+

Free trial

+

Buy now

+
+
+

Adobe Standard4

+

US$19.99/mo

+

Free trial

+

Buy now

+
+
+
+
+
+
+
+
+
+
+
+
+
E-signature core features signat core features
+
+
+
+
+
+
+
Right bold and Link
+
+
+
+
+
+
+
Sign agreements bold and Link
+
+
+
+
+
+
+
+

Track and manage agreements

+

+
+
+
+
+
+
+
+
+

Add a business stamp

+

+
+
+
+
+
+
+
+
+

Prepare forms

+

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Interact with PDFs
+
+
+
+
+
+
+
Collect signatures
+
+
+
+
+
+
+
Sign agreements
+
+
+
+
+
+
+
Track and manage agreements
+
+
+
+
+
+
+
Add a business stamp
+
+
+
+
+
+
+
Prepare forms
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
E-signature core features
+
+
+
+
+
+
+
Collect signatures
+
+
+
+
+
+
+
Sign agreements
+
+
+
+
+
+
+
+

Track and manage agreements

+

+
+
+
+
+
+
+
+
Add a business stamp
+
+
+
+
+
+
+
Prepare forms
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Interact with PDFs
+
+
+
+
+
+
+
Collect signatures
+
+
+
+
+
+
+
Sign agreements
+
+
+
+
+
+
+
Track and manage agreements
+
+
+
+
+
+
+
Add a business stamp
+
+
+
+
+
+
+
Prepare forms
+
+
+
+
+
+
-
-
-
-
-
Ee kj oyo kug it oi ooy o Bbibibi
-
e
-
-
-
-
-
Test1
-
-

Adobe Standard2

-

US$19.99/mo

-

Free trial

-

Buy now

-
-
-

Adobe Standard3

-

US$19.99/mo

-

Free trial

-

Buy now

-
-
-

Adobe Standard4

-

US$19.99/mo

-

Free trial

-

Buy now

-
-
-
-
-
-
-
-
-
-
-
-
-
E-signature core features signat core features
-
-
-
-
-
-
-
Right bold and Link
-
-
-
-
-
-
-
Sign agreements bold and Link
-
-
-
-
-
-
-
-

Track and manage agreements

-

-
-
-
-
-
-
-
-
-

Add a business stamp

-

-
-
-
-
-
-
-
-
-

Prepare forms

-

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Interact with PDFs
-
-
-
-
-
-
-
Collect signatures
-
-
-
-
-
-
-
Sign agreements
-
-
-
-
-
-
-
Track and manage agreements
-
-
-
-
-
-
-
Add a business stamp
-
-
-
-
-
-
-
Prepare forms
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
E-signature core features
-
-
-
-
-
-
-
Collect signatures
-
-
-
-
-
-
-
Sign agreements
-
-
-
-
-
-
-
-

Track and manage agreements

-

-
-
-
-
-
-
-
-
Add a business stamp
-
-
-
-
-
-
-
Prepare forms
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Interact with PDFs
-
-
-
-
-
-
-
Collect signatures
-
-
-
-
-
-
-
Sign agreements
-
-
-
-
-
-
-
Track and manage agreements
-
-
-
-
-
-
-
Add a business stamp
-
-
-
-
-
-
-
Prepare forms
-
-
-
-
-
-