Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

theme: allow passing ref to emotion theme provider

Abdullah Atta3d0eaacaace5
diff --git a/packages/theme/src/emotion/theme-provider.tsx b/packages/theme/src/emotion/theme-provider.tsx
index a5a9feeb9..e24f14452 100644
--- a/packages/theme/src/emotion/theme-provider.tsx
+++ b/packages/theme/src/emotion/theme-provider.tsx
@@ -25,16 +25,17 @@ import {
ScopedThemeProvider as NNScopedThemeProvider,
ThemeFactory
} from "../";
-import { PropsWithChildren, useMemo } from "react";
+import React, { ForwardedRef, PropsWithChildren, useMemo } from "react";
import { Box, BoxProps } from "@theme-ui/components";
export type EmotionThemeProviderProps = {
scope?: keyof ThemeScopes;
injectCssVars?: boolean;
-} & Omit<BoxProps, "variant">;
+} & Omit<BoxProps, "variant" | "ref">;
-export function EmotionThemeProvider(
- props: PropsWithChildren<EmotionThemeProviderProps>
+function _EmotionThemeProvider(
+ props: PropsWithChildren<EmotionThemeProviderProps>,
+ forwardedRef: ForwardedRef<HTMLDivElement>
) {
const {
children,
@@ -62,6 +63,7 @@ export function EmotionThemeProvider(
{injectCssVars ? (
<Box
{...restProps}
+ ref={forwardedRef}
className={`${
className ? className + " " : ""
}theme-scope-${scope}`}
@@ -75,3 +77,8 @@ export function EmotionThemeProvider(
</ThemeProvider>
);
}
+
+export const EmotionThemeProvider = React.forwardRef<
+ HTMLDivElement,
+ EmotionThemeProviderProps
+>(_EmotionThemeProvider);