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(menu): sort menu should be hide (#3505)

VicKun9530fe490e00
diff --git a/packages/sheets-sort-ui/src/controllers/sheets-sort.menu.ts b/packages/sheets-sort-ui/src/controllers/sheets-sort.menu.ts
index f31b820e7c..bcb33374b9 100644
--- a/packages/sheets-sort-ui/src/controllers/sheets-sort.menu.ts
+++ b/packages/sheets-sort-ui/src/controllers/sheets-sort.menu.ts
@@ -15,10 +15,10 @@
*/
import { UniverInstanceType } from '@univerjs/core';
+import { RangeProtectionPermissionEditPoint, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSortPermission } from '@univerjs/sheets';
+import { getCurrentExclusiveRangeInterest$, getCurrentRangeDisable$ } from '@univerjs/sheets-ui';
import { getMenuHiddenObservable, type IMenuItem, MenuItemType } from '@univerjs/ui';
import type { IAccessor } from '@univerjs/core';
-import { getCurrentRangeDisable$ } from '@univerjs/sheets-ui';
-import { RangeProtectionPermissionEditPoint, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSortPermission } from '@univerjs/sheets';
import { SortRangeAscCommand, SortRangeAscExtCommand, SortRangeAscExtInCtxMenuCommand, SortRangeAscInCtxMenuCommand, SortRangeCustomCommand, SortRangeCustomInCtxMenuCommand, SortRangeDescCommand, SortRangeDescExtCommand, SortRangeDescExtInCtxMenuCommand, SortRangeDescInCtxMenuCommand } from '../commands/commands/sheets-sort.command';
export const SHEETS_SORT_MENU_ID = 'sheet.menu.sheets-sort';
@@ -47,6 +47,7 @@ export function sortRangeAscMenuFactory(_accessor: IAccessor): IMenuItem {
icon: SHEETS_SORT_ASC_ICON,
title: 'sheets-sort.general.sort-asc-cur',
type: MenuItemType.BUTTON,
+ hidden$: getCurrentExclusiveRangeInterest$(_accessor),
};
}
diff --git a/packages/sheets-ui/src/controllers/status-bar.controller.ts b/packages/sheets-ui/src/controllers/status-bar.controller.ts
index 6df900b362..8492e88ec9 100644
--- a/packages/sheets-ui/src/controllers/status-bar.controller.ts
+++ b/packages/sheets-ui/src/controllers/status-bar.controller.ts
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import type { ICommandInfo, IRange, ISelectionCell, Nullable, Workbook } from '@univerjs/core';
import {
createInterceptorKey,
debounce,
@@ -29,24 +28,25 @@ import {
toDisposable,
UniverInstanceType,
} from '@univerjs/core';
-import type { ArrayValueObject, BaseValueObject, ISheetData } from '@univerjs/engine-formula';
import {
convertUnitDataToRuntime,
FormulaDataModel,
IFunctionService,
RangeReferenceObject,
} from '@univerjs/engine-formula';
-import type {
- ISelectionWithStyle,
-} from '@univerjs/sheets';
import {
INumfmtService,
SetRangeValuesMutation,
SheetsSelectionsService,
} from '@univerjs/sheets';
+import type { ICommandInfo, IRange, ISelectionCell, Nullable, Workbook } from '@univerjs/core';
+import type { ArrayValueObject, BaseValueObject, ISheetData } from '@univerjs/engine-formula';
+import type {
+ ISelectionWithStyle,
+} from '@univerjs/sheets';
-import type { IStatusBarServiceStatus } from '../services/status-bar.service';
import { IStatusBarService } from '../services/status-bar.service';
+import type { IStatusBarServiceStatus } from '../services/status-bar.service';
export const STATUS_BAR_PERMISSION_CORRECT = createInterceptorKey<ArrayValueObject[], ArrayValueObject[]>('statusBarPermissionCorrect');
@@ -149,6 +149,15 @@ export class StatusBarController extends Disposable {
});
if (selections?.length) {
+ if (selections.length === 1) {
+ const selection = selections[0];
+ const { startRow: start, endRow: end, startColumn: startCol, endColumn: endCol } = selection;
+ const rowCount = end - start + 1;
+ const columnCount = endCol - startCol + 1;
+ if (rowCount * columnCount > 1000000) {
+ return this._clearResult();
+ }
+ }
const realSelections: IRange[] = [];
selections.forEach((selection) => {
const { startRow: start, endRow: end } = selection;