From 3ea9c613a463888e9a1e64f0aa5b753f484e7fec Mon Sep 17 00:00:00 2001 From: manojava-gk Date: Wed, 12 Jul 2023 12:01:47 +0530 Subject: [PATCH 1/2] bugfix(static page): fix inline scroll height --- .../Cards/TitleDescriptionAndSectionlink.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/shared/templates/StaticTemplateResponsive/Cards/TitleDescriptionAndSectionlink.tsx b/src/components/shared/templates/StaticTemplateResponsive/Cards/TitleDescriptionAndSectionlink.tsx index cd40ec956..9161cd6dd 100644 --- a/src/components/shared/templates/StaticTemplateResponsive/Cards/TitleDescriptionAndSectionlink.tsx +++ b/src/components/shared/templates/StaticTemplateResponsive/Cards/TitleDescriptionAndSectionlink.tsx @@ -37,9 +37,9 @@ export default function TitleDescriptionAndSectionlink({ const navigateTo = (link: { internal: boolean; id: string }) => { if (link.internal) { const element = document.getElementById(link.id) - const top = element?.offsetTop + const top = element && element.offsetTop - 200 window.scrollTo({ - top: top, + top: top || 0, behavior: 'smooth', }) } else { From 4af17366f8b2223525a02e4b9bb782becbae80aa Mon Sep 17 00:00:00 2001 From: manojava-gk Date: Wed, 12 Jul 2023 12:05:08 +0530 Subject: [PATCH 2/2] bugfix(code smell): use ?? operator instead of || --- .../Cards/TitleDescriptionAndSectionlink.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/shared/templates/StaticTemplateResponsive/Cards/TitleDescriptionAndSectionlink.tsx b/src/components/shared/templates/StaticTemplateResponsive/Cards/TitleDescriptionAndSectionlink.tsx index 9161cd6dd..a6c71da87 100644 --- a/src/components/shared/templates/StaticTemplateResponsive/Cards/TitleDescriptionAndSectionlink.tsx +++ b/src/components/shared/templates/StaticTemplateResponsive/Cards/TitleDescriptionAndSectionlink.tsx @@ -39,7 +39,7 @@ export default function TitleDescriptionAndSectionlink({ const element = document.getElementById(link.id) const top = element && element.offsetTop - 200 window.scrollTo({ - top: top || 0, + top: top ?? 0, behavior: 'smooth', }) } else {