Skip to content

Commit f44fa09

Browse files
Revert "VIA-553 MD: Prevent window, document from failing and causing Minified React error #418"
This reverts commit 0097d3b.
1 parent 2f27861 commit f44fa09

File tree

5 files changed

+8
-20
lines changed

5 files changed

+8
-20
lines changed

src/app/_components/context/BrowserContext.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,10 @@ const BrowserContextProvider = ({ children }: { children: ReactNode }): JSX.Elem
2121
});
2222

2323
useEffect(() => {
24-
if (typeof window !== "undefined") {
25-
const isOpenInMobile: boolean = window.nhsapp?.tools?.isOpenInNHSApp?.() ?? false;
26-
setBrowserContext({
27-
hasContextLoaded: true,
28-
isOpenInMobileApp: isOpenInMobile,
29-
});
30-
}
24+
setBrowserContext({
25+
hasContextLoaded: true,
26+
isOpenInMobileApp: window.nhsapp?.tools.isOpenInNHSApp(),
27+
});
3128
}, []);
3229

3330
return <BrowserContext.Provider value={browserContext}>{children}</BrowserContext.Provider>;

src/app/_components/interceptor/LinksInterceptor.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use client";
2-
31
import { useBrowserContext } from "@src/app/_components/context/BrowserContext";
42
import { useEffect } from "react";
53

src/app/_components/nhs-app/BackToNHSAppLink.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { useBrowserContext } from "@src/app/_components/context/BrowserContext";
44
import React, { useEffect } from "react";
55

66
const handleClick = () => {
7-
if (typeof window === "undefined" || !window.nhsapp) return;
8-
97
const servicesPage = window.nhsapp.navigation.AppPage.SERVICES;
108
window.nhsapp.navigation.goToPage(servicesPage);
119
};
@@ -14,7 +12,7 @@ const BackToNHSAppLink = () => {
1412
const { hasContextLoaded, isOpenInMobileApp } = useBrowserContext();
1513

1614
useEffect(() => {
17-
if (hasContextLoaded && isOpenInMobileApp && window.nhsapp) {
15+
if (hasContextLoaded && isOpenInMobileApp) {
1816
window.nhsapp.navigation.setBackAction(handleClick);
1917
}
2018
}, [hasContextLoaded, isOpenInMobileApp]);

src/app/_components/nhs-frontend/SkipLink.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use client";
2-
31
import React from "react";
42

53
const SkipLink = () => {
@@ -10,11 +8,9 @@ const SkipLink = () => {
108
data-testid="skip-link"
119
onClick={(event) => {
1210
event.preventDefault();
13-
if (typeof document !== "undefined") {
14-
const contentTitle = document.getElementsByTagName("h1").item(0);
15-
contentTitle?.setAttribute("tabindex", "-1");
16-
contentTitle?.focus();
17-
}
11+
const contentTitle = document.getElementsByTagName("h1").item(0);
12+
contentTitle?.setAttribute("tabindex", "-1");
13+
contentTitle?.focus();
1814
}}
1915
>
2016
Skip to main content

src/utils/auth/inactivity-timer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const useInactivityTimer = (warningTimeMs: number = WARNING_TIME_MS, logoutTimeM
2727
}, [warningTimeMs, logoutTimeMs]);
2828

2929
useEffect(() => {
30-
if (typeof window === "undefined") return;
3130
ACTIVITY_EVENTS.forEach((event) => window.addEventListener(event, resetTimer));
3231

3332
resetTimer(); // Start timer on component mount

0 commit comments

Comments
 (0)