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.

feat(sheet-data-valiation): using cell-raw on data-validation (#2878)

zhangw935bdba18926
diff --git a/packages/sheets-data-validation/src/views/date-dropdown/index.tsx b/packages/sheets-data-validation/src/views/date-dropdown/index.tsx
index 4d5cdf21b5..7af4e60e56 100644
--- a/packages/sheets-data-validation/src/views/date-dropdown/index.tsx
+++ b/packages/sheets-data-validation/src/views/date-dropdown/index.tsx
@@ -55,7 +55,7 @@ export function DateDropdown(props: IDropdownComponentProps) {
const cellData = worksheet.getCell(row, col);
const rule = cellData?.dataValidation?.rule;
const validator = cellData?.dataValidation?.validator as DateValidator | undefined;
- const cellStr = getCellValueOrigin(cellData);
+ const cellStr = getCellValueOrigin(worksheet.getCellRaw(row, col));
const originDate = transformDate(cellStr);
const [localDate, setLocalDate] = useState<dayjs.Dayjs | undefined>(originDate);
const showTime = Boolean(rule?.bizInfo?.showTime);
diff --git a/packages/sheets-data-validation/src/views/list-dropdown/index.tsx b/packages/sheets-data-validation/src/views/list-dropdown/index.tsx
index 5348cc9bcd..bae9068b14 100644
--- a/packages/sheets-data-validation/src/views/list-dropdown/index.tsx
+++ b/packages/sheets-data-validation/src/views/list-dropdown/index.tsx
@@ -117,7 +117,7 @@ export function ListDropDown(props: IDropdownComponentProps) {
const multiple = rule.type === DataValidationType.LIST_MULTIPLE;
const list = validator.getListWithColor(rule, unitId, subUnitId);
- const cellStr = localValue || getDataValidationCellValue(cellData);
+ const cellStr = localValue || getDataValidationCellValue(worksheet.getCellRaw(row, col));
const value = deserializeListOptions(cellStr);
const handleEdit = () => {
diff --git a/packages/sheets-data-validation/src/widgets/checkbox-widget.ts b/packages/sheets-data-validation/src/widgets/checkbox-widget.ts
index b15faf142f..f6c36186d5 100644
--- a/packages/sheets-data-validation/src/widgets/checkbox-widget.ts
+++ b/packages/sheets-data-validation/src/widgets/checkbox-widget.ts
@@ -93,9 +93,9 @@ export class CheckboxRender implements IBaseDataValidationWidget {
}
drawWith(ctx: UniverRenderingContext2D, info: ICellRenderContext): void {
- const { style, data, primaryWithCoord, unitId, subUnitId } = info;
+ const { style, data, primaryWithCoord, unitId, subUnitId, worksheet, row, col } = info;
const cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord;
- const value = getCellValueOrigin(data);
+ const value = getCellValueOrigin(worksheet.getCellRaw(row, col));
const rule = data.dataValidation?.rule;
const validator = data.dataValidation?.validator as CheckboxValidator;
if (!rule || !validator) {
@@ -170,8 +170,8 @@ export class CheckboxRender implements IBaseDataValidationWidget {
if (evt.button === 2) {
return;
}
- const { primaryWithCoord, unitId, subUnitId, data } = info;
- const value = getCellValueOrigin(data);
+ const { primaryWithCoord, unitId, subUnitId, data, worksheet, row, col } = info;
+ const value = getCellValueOrigin(worksheet.getCellRaw(row, col));
const rule = data.dataValidation?.rule;
const validator = data.dataValidation?.validator as BaseDataValidator;
if (!rule || !validator) {