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(numfmt): reselect item and throw error (#2611)

Gpound.liu9902edb6afeb
diff --git a/packages/sheets-numfmt/src/components/currency/index.tsx b/packages/sheets-numfmt/src/components/currency/index.tsx
index df81b65086..05dd7f1736 100644
--- a/packages/sheets-numfmt/src/components/currency/index.tsx
+++ b/packages/sheets-numfmt/src/components/currency/index.tsx
@@ -54,6 +54,9 @@ export const CurrencyPanel: FC<IBusinessComponentProps> = (props) => {
props.action.current = () => setPatternDecimal(pattern, decimal);
const onSelect = (value: string) => {
+ if (value === undefined) {
+ return;
+ }
suffixSet(value);
const pattern = getCurrencyFormatOptions(value)[0].value;
patternSet(pattern);
@@ -61,6 +64,9 @@ export const CurrencyPanel: FC<IBusinessComponentProps> = (props) => {
};
const onChange = (value: any) => {
+ if (value === undefined) {
+ return;
+ }
patternSet(value);
props.onChange(setPatternDecimal(value, decimal));
};
diff --git a/packages/sheets-numfmt/src/components/date/index.tsx b/packages/sheets-numfmt/src/components/date/index.tsx
index 03b47a01c2..0d2703a248 100644
--- a/packages/sheets-numfmt/src/components/date/index.tsx
+++ b/packages/sheets-numfmt/src/components/date/index.tsx
@@ -50,6 +50,9 @@ export const DatePanel: FC<IBusinessComponentProps> = (props) => {
props.action.current = () => suffix;
const onChange = (v: any) => {
+ if (v === undefined) {
+ return;
+ }
suffixSet(v);
props.onChange(v);
};
diff --git a/packages/sheets-numfmt/src/components/thousandth-percentile/index.tsx b/packages/sheets-numfmt/src/components/thousandth-percentile/index.tsx
index 168c7e9b4e..45da9a41a3 100644
--- a/packages/sheets-numfmt/src/components/thousandth-percentile/index.tsx
+++ b/packages/sheets-numfmt/src/components/thousandth-percentile/index.tsx
@@ -52,6 +52,9 @@ export const ThousandthPercentilePanel: FC<IBusinessComponentProps> = (props) =>
props.onChange(setPatternDecimal(suffix, Number(decimal || 0)));
};
const handleClick = (v: any) => {
+ if (v === undefined) {
+ return;
+ }
decimalSet(getDecimalFromPattern(v, 0));
suffixSet(v);
props.onChange(v);