Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(design): ensure popup component is appended to root to prevent offset from stacking contexts (#1850)
白熱1ad518a8ba42
diff --git a/packages/design/src/components/popup/Popup.tsx b/packages/design/src/components/popup/Popup.tsxindex 3887fdf34c..9caf386852 100644--- a/packages/design/src/components/popup/Popup.tsx+++ b/packages/design/src/components/popup/Popup.tsx@@ -14,9 +14,11 @@* limitations under the License.*/-import React, { useEffect, useRef, useState } from 'react';+import React, { useContext, useEffect, useRef, useState } from 'react';+import { createPortal } from 'react-dom';import { CSSTransition } from 'react-transition-group';+import { ConfigContext } from '../config-provider/ConfigProvider';import styles from './index.module.less';export interface IPopupProps {@@ -42,6 +44,8 @@ export function Popup(props: IPopupProps) {const [realOffset, setRealOffset] = useState<[number, number]>(offset);+ const { mountContainer } = useContext(ConfigContext);+useEffect(() => {if (!visible) {setRealOffset([-9999, -9999]);@@ -62,7 +66,7 @@ export function Popup(props: IPopupProps) {event.preventDefault();}- return (+ return createPortal(<CSSTransitionin={visible}nodeRef={nodeRef}@@ -89,6 +93,7 @@ export function Popup(props: IPopupProps) {>{children}</section>- </CSSTransition>+ </CSSTransition>,+ mountContainer!);}diff --git a/packages/ui/src/components/editor/TextEditor.tsx b/packages/ui/src/components/editor/TextEditor.tsxindex e4f3c0a4ce..8f746575b8 100644--- a/packages/ui/src/components/editor/TextEditor.tsx+++ b/packages/ui/src/components/editor/TextEditor.tsx@@ -185,7 +185,7 @@ export function TextEditor(props: ITextEditorProps & Omit<MyComponentProps, 'onCsetValidationVisible(!isLegality);const rect = editor.getBoundingClientRect();- setValidationOffset([rect.left, rect.top - 16]);+ setValidationOffset([rect.left, rect.top]);if (editor.onlyInputFormula()) {setValidationContent(localeService.t('textEditor.formulaError'));