diff --git a/packages/next/src/views/LivePreview/IFrame/index.tsx b/packages/next/src/views/LivePreview/IFrame/index.tsx index d057c4d3d80..581bc9d8c61 100644 --- a/packages/next/src/views/LivePreview/IFrame/index.tsx +++ b/packages/next/src/views/LivePreview/IFrame/index.tsx @@ -1,5 +1,5 @@ 'use client' -import React, { forwardRef } from 'react' +import React from 'react' import { useLivePreviewContext } from '../Context/context.js' import './index.scss' @@ -7,12 +7,13 @@ import './index.scss' const baseClass = 'live-preview-iframe' type Props = { + ref: React.RefObject setIframeHasLoaded: (value: boolean) => void url: string } -export const IFrame = forwardRef((props, ref) => { - const { setIframeHasLoaded, url } = props +export const IFrame: React.FC = (props) => { + const { ref, setIframeHasLoaded, url } = props const { zoom } = useLivePreviewContext() @@ -30,4 +31,4 @@ export const IFrame = forwardRef((props, ref) => { title={url} /> ) -}) +} diff --git a/packages/ui/src/elements/Button/index.tsx b/packages/ui/src/elements/Button/index.tsx index 7ac48451868..9831374c79f 100644 --- a/packages/ui/src/elements/Button/index.tsx +++ b/packages/ui/src/elements/Button/index.tsx @@ -1,5 +1,5 @@ 'use client' -import React, { forwardRef, Fragment, isValidElement } from 'react' +import React, { Fragment, isValidElement } from 'react' import type { Props } from './types.js' @@ -47,7 +47,7 @@ export const ButtonContents = ({ children, icon, showTooltip, tooltip }) => { ) } -export const Button = forwardRef((props, ref) => { +export const Button: React.FC = (props) => { const { id, type = 'button', @@ -64,6 +64,7 @@ export const Button = forwardRef(( newTab, onClick, onMouseDown, + ref, round, size = 'medium', SubMenuPopupContent, @@ -131,7 +132,7 @@ export const Button = forwardRef(( } + ref={ref as React.RefObject} > {children} @@ -195,4 +196,4 @@ export const Button = forwardRef(( } return buttonElement -}) +} diff --git a/packages/ui/src/elements/Button/types.ts b/packages/ui/src/elements/Button/types.ts index 3a7b1a66bb7..6d7d2f5d3a4 100644 --- a/packages/ui/src/elements/Button/types.ts +++ b/packages/ui/src/elements/Button/types.ts @@ -5,6 +5,7 @@ type secondaryAction = { label: string onClick: (event: MouseEvent) => void } + export type Props = { 'aria-label'?: string buttonId?: string @@ -29,6 +30,7 @@ export type Props = { * @default false */ programmaticSubmit?: boolean + ref?: React.RefObject round?: boolean secondaryActions?: secondaryAction | secondaryAction[] size?: 'large' | 'medium' | 'small' diff --git a/packages/ui/src/elements/EditUpload/index.tsx b/packages/ui/src/elements/EditUpload/index.tsx index e962b84f9b2..6528addb3d1 100644 --- a/packages/ui/src/elements/EditUpload/index.tsx +++ b/packages/ui/src/elements/EditUpload/index.tsx @@ -3,7 +3,7 @@ import type { UploadEdits } from 'payload' import { useModal } from '@faceless-ui/modal' -import React, { forwardRef, useRef, useState } from 'react' +import React, { useRef, useState } from 'react' import ReactCrop from 'react-image-crop' import 'react-image-crop/dist/ReactCrop.css' @@ -18,11 +18,12 @@ const baseClass = 'edit-upload' type Props = { name: string onChange: (value: string) => void + ref?: React.RefObject value: string } -const Input = forwardRef((props, ref) => { - const { name, onChange, value } = props +const Input: React.FC = (props) => { + const { name, onChange, ref, value } = props return (
@@ -36,7 +37,7 @@ const Input = forwardRef((props, ref) => { />
) -}) +} type FocalPosition = { x: number diff --git a/packages/ui/src/elements/Gutter/index.tsx b/packages/ui/src/elements/Gutter/index.tsx index 3e926705309..296400bb723 100644 --- a/packages/ui/src/elements/Gutter/index.tsx +++ b/packages/ui/src/elements/Gutter/index.tsx @@ -1,5 +1,5 @@ 'use client' -import React, { forwardRef } from 'react' +import React from 'react' import './index.scss' @@ -9,18 +9,20 @@ export type GutterProps = { left?: boolean negativeLeft?: boolean negativeRight?: boolean + ref?: React.RefObject right?: boolean } const baseClass = 'gutter' -export const Gutter = forwardRef((props, ref) => { +export const Gutter: React.FC = (props) => { const { children, className, left = true, negativeLeft = false, negativeRight = false, + ref, right = true, } = props @@ -43,6 +45,6 @@ export const Gutter = forwardRef((props, ref) => { {children} ) -}) +} Gutter.displayName = 'Gutter' diff --git a/packages/ui/src/forms/Submit/index.tsx b/packages/ui/src/forms/Submit/index.tsx index c8f047288f6..ecf5ed4f252 100644 --- a/packages/ui/src/forms/Submit/index.tsx +++ b/packages/ui/src/forms/Submit/index.tsx @@ -1,5 +1,5 @@ 'use client' -import React, { forwardRef } from 'react' +import React from 'react' import type { Props } from '../../elements/Button/types.js' @@ -9,7 +9,7 @@ import './index.scss' const baseClass = 'form-submit' -export const FormSubmit = forwardRef((props, ref) => { +export const FormSubmit: React.FC = (props) => { const { type = 'submit', buttonId: id, @@ -17,7 +17,9 @@ export const FormSubmit = forwardRef((props, ref) => { disabled: disabledFromProps, onClick, programmaticSubmit, + ref, } = props + const processing = useFormProcessing() const initializing = useFormInitializing() const { disabled, submit } = useForm() @@ -46,4 +48,4 @@ export const FormSubmit = forwardRef((props, ref) => { ) -}) +} diff --git a/packages/ui/src/utilities/getClientConfig.ts b/packages/ui/src/utilities/getClientConfig.ts index a92314c5c5f..6d18a95d19e 100644 --- a/packages/ui/src/utilities/getClientConfig.ts +++ b/packages/ui/src/utilities/getClientConfig.ts @@ -15,6 +15,7 @@ export const getClientConfig = cache( if (cachedClientConfig && !global._payload_doNotCacheClientConfig) { return cachedClientConfig } + const { config, i18n, importMap } = args cachedClientConfig = createClientConfig({ @@ -22,6 +23,7 @@ export const getClientConfig = cache( i18n, importMap, }) + global._payload_clientConfig = cachedClientConfig global._payload_doNotCacheClientConfig = false