Skip to content

Commit 79b52ff

Browse files
committed
fix: Uncaught Error: document is not defined for SSR (adobe#7926)
Fix error when window is set but document is undefined when running SSR. Modify test input data to show problem. Ignore lint error in testfile
1 parent 1457ded commit 79b52ff

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

packages/@react-aria/interactions/src/useFocusVisible.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ function handleWindowBlur() {
123123
* Setup global event listeners to control when keyboard focus style should be visible.
124124
*/
125125
function setupGlobalFocusEvents(element?: HTMLElement | null) {
126-
if (typeof window === 'undefined' || hasSetupGlobalListeners.get(getOwnerWindow(element))) {
126+
if (typeof window === 'undefined' || typeof document === 'undefined' || hasSetupGlobalListeners.get(getOwnerWindow(element))) {
127127
return;
128128
}
129129

packages/dev/test-utils/src/ssrWorker.js

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ ignoreStyles.default(undefined, (module) => {
2121
module.exports = identityObjectProxy;
2222
});
2323

24+
// eslint-disable-next-line no-global-assign
25+
window = {};
26+
2427
require('@babel/register')({
2528
extensions: ['.js', '.ts', '.tsx']
2629
});

0 commit comments

Comments
 (0)