Skip to content

TypeError: Cannot read properties of undefined (reading 'CSSStyleSheet') when defaultView is undefinedΒ #559

@mkaczkowski

Description

@mkaczkowski

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch [email protected] for the project I'm working on.

Problem

When using react-resizable-panels with Vite + React 19, I encountered a runtime error on pointer move:

Uncaught TypeError: Cannot read properties of undefined (reading 'CSSStyleSheet')
    at ae (updateCursorStyle.ts:20:48)
    at HTMLDocument.Le (onDocumentPointerMove.ts:64:7)

In src/utils/dom/updateCursorStyle.ts, the guard checks if (document.defaultView === null) but document.defaultView can be undefined in certain contexts (Vite HMR, SSR hydration). Since undefined !== null, the guard passes and crashes when accessing defaultView.CSSStyleSheet.

This appears related to PR #555 which addressed popup window support, but the fix was incomplete for the undefined case.

Suggested Fix

In src/utils/dom/updateCursorStyle.ts, change:

if (document.defaultView === null) return;

to:

if (!document.defaultView) return;

Here is the diff that solved my problem (applied to dist files):

-  if (e.defaultView === null)
+  if (!e.defaultView)
     return;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions