Skip to content

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.

fix(editor): state error (#2552)

Univer819bbe72c8de
diff --git a/packages/ui/src/components/editor/TextEditor.tsx b/packages/ui/src/components/editor/TextEditor.tsx
index 40e69a618d..dc072b07c5 100644
--- a/packages/ui/src/components/editor/TextEditor.tsx
+++ b/packages/ui/src/components/editor/TextEditor.tsx
@@ -192,7 +192,7 @@ export function TextEditor(props: ITextEditorProps & Omit<MyComponentProps, 'onC
const rect = editor.getBoundingClientRect();
setValidationOffset([rect.left, rect.top - 16]);
if (rect.left + rect.top > 0) {
- setValidationVisible(!isLegality);
+ setValidationVisible(isLegality);
}
if (editor.onlyInputFormula()) {
@@ -280,7 +280,7 @@ export function TextEditor(props: ITextEditorProps & Omit<MyComponentProps, 'onC
if (props.className == null) {
if (isReadonly) {
borderStyle = ` ${styles.textEditorContainerDisabled}`;
- } else if (validationVisible) {
+ } else if (!validationVisible) {
borderStyle = ` ${styles.textEditorContainerError}`;
} else if (active) {
borderStyle = ` ${styles.textEditorContainerActive}`;
@@ -292,7 +292,7 @@ export function TextEditor(props: ITextEditorProps & Omit<MyComponentProps, 'onC
<div {...propsNew} className={className + borderStyle} ref={editorRef}>
<div style={{ display: hasValue() ? 'none' : 'unset' }} className={styles.textEditorContainerPlaceholder}>{placeholder}</div>
</div>
- <Popup visible={validationVisible} offset={validationOffset}>
+ <Popup visible={!validationVisible} offset={validationOffset}>
<div className={styles.textEditorValidationError}>{validationContent}</div>
</Popup>
</>