Skip to content

Commit

Permalink
Fix for WindowProvider utilities always returning window/document/und…
Browse files Browse the repository at this point in the history
…efined (microsoft#31968)
  • Loading branch information
Jamie0 authored Jul 17, 2024
1 parent 8f32934 commit dd5120e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Fix WindowProvider utilities always returning window/document/undefined",
"packageName": "@fluentui/react",
"email": "[email protected]",
"dependentChangeType": "patch"
}
8 changes: 4 additions & 4 deletions packages/react/src/utilities/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { useDocument, useWindow, WindowProviderProps } from '@fluentui/react-win
*/
export const useDocumentEx = () => {
// eslint-disable-next-line no-restricted-globals
return useDocument() ?? typeof document !== 'undefined' ? document : undefined;
return useDocument() ?? (typeof document !== 'undefined' ? document : undefined);
};

/**
Expand All @@ -27,7 +27,7 @@ export const useDocumentEx = () => {
*/
export const useWindowEx = () => {
// eslint-disable-next-line no-restricted-globals
return useWindow() ?? typeof window !== 'undefined' ? window : undefined;
return useWindow() ?? (typeof window !== 'undefined' ? window : undefined);
};

/**
Expand All @@ -39,7 +39,7 @@ export const useWindowEx = () => {
*/
export const getDocumentEx = (ctx: Pick<WindowProviderProps, 'window'> | undefined) => {
// eslint-disable-next-line no-restricted-globals
return ctx?.window?.document ?? typeof document !== 'undefined' ? document : undefined;
return ctx?.window?.document ?? (typeof document !== 'undefined' ? document : undefined);
};

/**
Expand All @@ -51,5 +51,5 @@ export const getDocumentEx = (ctx: Pick<WindowProviderProps, 'window'> | undefin
*/
export const getWindowEx = (ctx: Pick<WindowProviderProps, 'window'> | undefined) => {
// eslint-disable-next-line no-restricted-globals
return ctx?.window ?? typeof window !== 'undefined' ? window : undefined;
return ctx?.window ?? (typeof window !== 'undefined' ? window : undefined);
};

0 comments on commit dd5120e

Please sign in to comment.