Skip to content

Commit 36a6a19

Browse files
authored
fix(ui): css is not defined error in production build (#9603)
Related: #9456 Fixes #9598 This ensures that the `CSS` property is accessed safely, preventing the "CSS is not defined" error
1 parent 3da9be0 commit 36a6a19

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

packages/ui/src/elements/AnimateHeight/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use client'
12
import React, { useEffect, useRef } from 'react'
23

34
import { usePatchAnimateHeight } from './usePatchAnimateHeight.js'

packages/ui/src/elements/AnimateHeight/usePatchAnimateHeight.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use client'
12
import { useEffect, useMemo, useRef } from 'react'
23

34
export const usePatchAnimateHeight = ({
@@ -10,7 +11,10 @@ export const usePatchAnimateHeight = ({
1011
open: boolean
1112
}): { browserSupportsKeywordAnimation: boolean } => {
1213
const browserSupportsKeywordAnimation = useMemo(
13-
() => (CSS.supports ? Boolean(CSS.supports('interpolate-size', 'allow-keywords')) : false),
14+
() =>
15+
typeof CSS !== 'undefined' && CSS && CSS.supports
16+
? Boolean(CSS.supports('interpolate-size', 'allow-keywords'))
17+
: false,
1418
[],
1519
)
1620

0 commit comments

Comments
 (0)