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.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix: should not get sheet selection when it was disposed (#5006)
YuHong6d3f67b068ae
diff --git a/packages/sheets-drawing-ui/src/controllers/render-controllers/sheet-celll-image-hover.render-controller.ts b/packages/sheets-drawing-ui/src/controllers/render-controllers/sheet-celll-image-hover.render-controller.tsindex 355d82ae88..8fcd025582 100644--- a/packages/sheets-drawing-ui/src/controllers/render-controllers/sheet-celll-image-hover.render-controller.ts+++ b/packages/sheets-drawing-ui/src/controllers/render-controllers/sheet-celll-image-hover.render-controller.ts@@ -19,7 +19,7 @@ import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';import { Disposable, Inject } from '@univerjs/core';import { DrawingRenderService } from '@univerjs/drawing-ui';import { CURSOR_TYPE } from '@univerjs/engine-render';-import { SheetsSelectionsService } from '@univerjs/sheets';+import { type ISelectionWithStyle, SheetsSelectionsService } from '@univerjs/sheets';import { HoverManagerService, SheetSkeletonManagerService } from '@univerjs/sheets-ui';import { throttleTime } from 'rxjs';@@ -42,8 +42,13 @@ export class SheetCellImageHoverRenderController extends Disposable implements Ithis.disposeWithMe(this._hoverManagerService.currentRichTextNoDistinct$.pipe(throttleTime(33)).subscribe((richText) => {- const currentSelections = this._selectionsService.getWorkbookSelections(this._context.unitId).getCurrentSelections();+ let currentSelections: Readonly<ISelectionWithStyle[]> = [];+ // null richText means the unit was disposed, should not get current selections+ if (richText !== null) {+ currentSelections = this._selectionsService.getWorkbookSelections(this._context.unitId).getCurrentSelections();+ }if (+ currentSelections.length > 0 &&richText?.unitId === this._context.unitId &&richText?.drawing &¤tSelections.length === 1 &&