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(range-selector): placeholder flush (#2607)

Gpound.liu2dc7ce04fee4
diff --git a/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/index.tsx b/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/index.tsx
index adaad4748d..347adee5d3 100644
--- a/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/index.tsx
+++ b/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/index.tsx
@@ -91,39 +91,39 @@ export const RuleEdit = (props: IRuleEditProps) => {
return defaultType;
}
switch (type) {
- case CFRuleType.highlightCell:{
+ case CFRuleType.highlightCell: {
const subType = props.rule?.rule.subType;
switch (subType) {
case CFSubRuleType.number:
case CFSubRuleType.text:
case CFSubRuleType.duplicateValues:
case CFSubRuleType.uniqueValues:
- case CFSubRuleType.timePeriod:{
+ case CFSubRuleType.timePeriod: {
return '1';
}
case CFSubRuleType.average:
- case CFSubRuleType.rank:{
+ case CFSubRuleType.rank: {
return '2';
}
- case CFSubRuleType.formula:{
+ case CFSubRuleType.formula: {
return '5';
}
}
break;
}
- case CFRuleType.dataBar:{
+ case CFRuleType.dataBar: {
return '3';
}
- case CFRuleType.colorScale:{
+ case CFRuleType.colorScale: {
return '4';
}
- case CFRuleType.iconSet:{
+ case CFRuleType.iconSet: {
return '6';
}
}
return defaultType;
});
- const result = useRef < Parameters<IStyleEditorProps['onChange']>>();
+ const result = useRef<Parameters<IStyleEditorProps['onChange']>>();
const interceptorManager = useMemo(() => {
const _interceptorManager = new InterceptorManager({ beforeSubmit, submit });
return _interceptorManager;
@@ -131,25 +131,25 @@ export const RuleEdit = (props: IRuleEditProps) => {
const StyleEditor = useMemo(() => {
switch (ruleType) {
- case '1':{
+ case '1': {
return HighlightCellStyleEditor;
}
- case '2':{
+ case '2': {
return RankStyleEditor;
}
- case '3':{
+ case '3': {
return DataBarStyleEditor;
}
- case '4':{
+ case '4': {
return ColorScaleStyleEditor;
}
- case '5':{
+ case '5': {
return FormulaStyleEditor;
}
- case '6':{
+ case '6': {
return IconSet;
}
- default :{
+ default: {
return HighlightCellStyleEditor;
}
}
@@ -224,7 +224,15 @@ export const RuleEdit = (props: IRuleEditProps) => {
<div className={styles.cfRuleStyleEditor}>
<div className={styleBase.title}>{localeService.t('sheet.cf.panel.range')}</div>
<div className={`${styleBase.mTBase}`}>
- <RangeSelector placeholder={localeService.t('sheet.cf.form.rangeSelector')} width={'100%' as unknown as number} openForSheetSubUnitId={subUnitId} openForSheetUnitId={unitId} value={rangeString} id={createInternalEditorID(`${SHEET_CONDITIONAL_FORMATTING_PLUGIN}_rangeSelector`)} onChange={onRangeSelectorChange} />
+ <RangeSelector
+ placeholder={localeService.t('sheet.cf.form.rangeSelector')}
+ width={'100%' as unknown as number}
+ openForSheetSubUnitId={subUnitId}
+ openForSheetUnitId={unitId}
+ value={rangeString}
+ id={createInternalEditorID(`${SHEET_CONDITIONAL_FORMATTING_PLUGIN}_rangeSelector`)}
+ onChange={onRangeSelectorChange}
+ />
</div>
<div className={styleBase.title}>{localeService.t('sheet.cf.panel.styleType')}</div>
<div className={styleBase.mTBase}>
diff --git a/packages/ui/src/components/editor/TextEditor.tsx b/packages/ui/src/components/editor/TextEditor.tsx
index dc072b07c5..43638f9ec0 100644
--- a/packages/ui/src/components/editor/TextEditor.tsx
+++ b/packages/ui/src/components/editor/TextEditor.tsx
@@ -115,8 +115,6 @@ export function TextEditor(props: ITextEditorProps & Omit<MyComponentProps, 'onC
onValid,
- placeholder = '',
-
isValueValid = true,
} = props;
@@ -124,6 +122,8 @@ export function TextEditor(props: ITextEditorProps & Omit<MyComponentProps, 'onC
const localeService = useDependency(LocaleService);
+ const [placeholder, placeholderSet] = useState('');
+
const [validationContent, setValidationContent] = useState<string>('');
const [validationVisible, setValidationVisible] = useState(isValueValid);
@@ -171,6 +171,9 @@ export function TextEditor(props: ITextEditorProps & Omit<MyComponentProps, 'onC
},
editor);
+ editorService.setValueNoRefresh(props.value || '', id);
+ placeholderSet(props.placeholder || '');
+
const activeChange = debounce((state: boolean) => {
setActive(state);
onActive && onActive(state);