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(sheet-formula-ui): correct sheet name retrieval in selection (#5414)

WEI ZHANG37a3fe0e4650
diff --git a/packages/sheets-formula-ui/src/views/formula-editor/hooks/use-sheet-selection-change.ts b/packages/sheets-formula-ui/src/views/formula-editor/hooks/use-sheet-selection-change.ts
index 594cba8164..763d36bb6b 100644
--- a/packages/sheets-formula-ui/src/views/formula-editor/hooks/use-sheet-selection-change.ts
+++ b/packages/sheets-formula-ui/src/views/formula-editor/hooks/use-sheet-selection-change.ts
@@ -106,7 +106,7 @@ export const useSheetSelectionChange = (
const unitRangeName = {
range,
unitId: range.unitId ?? currentUnit!.getUnitId(),
- sheetName: getSheetNameById(unitId, rangeSheetId),
+ sheetName: getSheetNameById(range.unitId ?? currentUnit!.getUnitId(), rangeSheetId),
};
const isAcrossSheet = rangeSheetId !== subUnitId;
const isAcrossWorkbook = currentUnit?.getUnitId() !== unitId;
@@ -121,7 +121,7 @@ export const useSheetSelectionChange = (
const unitRangeName = {
range,
unitId: range.unitId ?? currentUnit!.getUnitId(),
- sheetName: getSheetNameById(unitId, rangeSheetId),
+ sheetName: getSheetNameById(range.unitId ?? currentUnit!.getUnitId(), rangeSheetId),
};
const isAcrossSheet = rangeSheetId !== subUnitId;
const isAcrossWorkbook = currentUnit?.getUnitId() !== unitId;
@@ -173,7 +173,7 @@ export const useSheetSelectionChange = (
const unitRangeName = {
range: selection,
unitId: selection.unitId ?? currentUnit!.getUnitId(),
- sheetName: getSheetNameById(unitId, rangeSheetId),
+ sheetName: getSheetNameById(selection.unitId ?? currentUnit!.getUnitId(), rangeSheetId),
};
const isAcrossWorkbook = currentUnit?.getUnitId() !== unitId;
const isAcrossSheet = rangeSheetId !== subUnitId;
@@ -198,7 +198,7 @@ export const useSheetSelectionChange = (
const unitRangeName = {
range: selection,
unitId: selection.unitId ?? currentUnit!.getUnitId(),
- sheetName: getSheetNameById(unitId, rangeSheetId),
+ sheetName: getSheetNameById(selection.unitId ?? currentUnit!.getUnitId(), rangeSheetId),
};
const isAcrossWorkbook = currentUnit?.getUnitId() !== unitId;
const isAcrossSheet = rangeSheetId !== subUnitId;