Skip to content

Commit

Permalink
fix: check if window is defined for ssr
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaacmaamouche committed Aug 22, 2023
1 parent b71b181 commit 33408c0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/Tabs/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
//Check if the element, or its parent, has a scale property
export const getParentScale = (element: HTMLElement | null): number => {
if (!element) return 1
//If the element doesn't exist, or if window is undefined, return 1
if (!element || typeof window === 'undefined') return 1
const elementScale = Number(window.getComputedStyle(element).scale)

//If the scale property is not unvalid or undefined, return its value
//Else check the parent's scale property
if (!isNaN(elementScale)) {
return elementScale
} else {
Expand Down

0 comments on commit 33408c0

Please sign in to comment.