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(ui): harden print preparation state (#7534)

Univerbbad43f7043b
diff --git a/packages/docs-ui/src/controllers/ui.controller.ts b/packages/docs-ui/src/controllers/ui.controller.ts
index f699f9458e..3a651917c3 100644
--- a/packages/docs-ui/src/controllers/ui.controller.ts
+++ b/packages/docs-ui/src/controllers/ui.controller.ts
@@ -128,7 +128,11 @@ export class DocUIController extends Disposable {
}
const renderManagerService = this._injector.get(IRenderManagerService);
- const docSelectionRenderService = renderManagerService.getRenderUnitById(unitId)!.with(DocSelectionRenderService);
+ const renderUnit = renderManagerService.getRenderUnitById(unitId);
+ if (!renderUnit) {
+ return;
+ }
+ const docSelectionRenderService = renderUnit.with(DocSelectionRenderService);
docSelectionRenderService.focus();
})
diff --git a/packages/ui/src/views/hooks/virtual-list.ts b/packages/ui/src/views/hooks/virtual-list.ts
index 3216e9042f..ee9c448ed3 100644
--- a/packages/ui/src/views/hooks/virtual-list.ts
+++ b/packages/ui/src/views/hooks/virtual-list.ts
@@ -15,6 +15,7 @@
*/
import type { Nullable } from '@univerjs/core';
+import type { RefObject } from 'react';
import { useEffect, useMemo, useRef, useState } from 'react';
import { useEvent } from './event';
@@ -23,7 +24,7 @@ type ItemHeight<T> = (index: number, data: T) => number;
const isNumber = (value: unknown): value is number => typeof value === 'number';
export interface IVirtualListOptions<T> {
- containerTarget: React.RefObject<HTMLElement>;
+ containerTarget: RefObject<HTMLElement | null>;
itemHeight: number | ItemHeight<T>;
overscan?: number;
}