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(sheet): filterRenderController work after selectionRenderControll… (#2229)
siam8f8e80d1051b
diff --git a/packages/sheets-filter-ui/src/controllers/sheets-filter-render.controller.ts b/packages/sheets-filter-ui/src/controllers/sheets-filter-render.controller.tsindex 4fd908bc9a..e54c76ffec 100644--- a/packages/sheets-filter-ui/src/controllers/sheets-filter-render.controller.ts+++ b/packages/sheets-filter-ui/src/controllers/sheets-filter-render.controller.ts@@ -26,7 +26,7 @@ import { getCoordByCell, ISelectionRenderService, SelectionShape, SheetRenderConimport type { IDisposable } from '@wendellhu/redi';import { Inject, Injector } from '@wendellhu/redi';-import { filter, map, of, startWith, switchMap, takeUntil, throttleTime } from 'rxjs';+import { combineLatest, filter, map, of, startWith, switchMap, takeUntil, throttleTime } from 'rxjs';import type { ISheetsFilterButtonShapeProps } from '../views/widgets/filter-button.shape';import { FILTER_ICON_PADDING, FILTER_ICON_SIZE, SheetsFilterButtonShape } from '../views/widgets/filter-button.shape';@@ -91,17 +91,20 @@ export class SheetsFilterRenderController extends RxDisposable implements IRendeskeleton: skeletonParams.skeleton,});- return fromCallback(this._commandService.onCommandExecuted)- .pipe(- filter(([command]) =>- command.type === CommandType.MUTATION- && (command.params as ISheetCommandSharedParams).unitId === workbook.getUnitId()- && FILTER_MUTATIONS.has(command.id)- ),- throttleTime(20, undefined, { leading: false, trailing: true }),- map(getParams),- startWith(getParams()) // must trigger once- );+ return combineLatest([+ this._selectionRenderService.usable$,+ fromCallback(this._commandService.onCommandExecuted),+ ]).pipe(+ filter(([usable, [command]]) =>+ usable+ && command.type === CommandType.MUTATION+ && (command.params as ISheetCommandSharedParams).unitId === workbook.getUnitId()+ && FILTER_MUTATIONS.has(command.id)+ ),+ throttleTime(20, undefined, { leading: false, trailing: true }),+ map(getParams),+ startWith(getParams()) // must trigger once+ );}),takeUntil(this.dispose$))diff --git a/packages/sheets-ui/src/services/selection/selection-render.service.ts b/packages/sheets-ui/src/services/selection/selection-render.service.tsindex 73ec52a988..204cfc00a7 100644--- a/packages/sheets-ui/src/services/selection/selection-render.service.ts+++ b/packages/sheets-ui/src/services/selection/selection-render.service.ts@@ -50,6 +50,7 @@ export interface ISelectionRenderService {readonly controlFillConfig$: Observable<IControlFillConfig | null>;readonly selectionMoving$: Observable<ISelectionWithCoordAndStyle[]>;readonly selectionMoveStart$: Observable<ISelectionWithCoordAndStyle[]>;+ readonly usable$: Observable<boolean>;enableHeaderHighlight(): void;disableHeaderHighlight(): void;@@ -194,6 +195,14 @@ export class SelectionRenderService implements ISelectionRenderService {private _activeViewport: Nullable<Viewport>;+ /**+ * This service relies on the scene and skeleton to work+ * Use usable$ to check if this service works+ */+ private readonly _usable$ = new Subject<boolean>();++ readonly usable$ = this._usable$.asObservable();+constructor(@Inject(ThemeService) private readonly _themeService: ThemeService,@IShortcutService private readonly _shortcutService: IShortcutService,@@ -352,6 +361,7 @@ export class SelectionRenderService implements ISelectionRenderService {this._skeleton = skeleton;this._scene = scene;this._activeViewport = viewport || scene?.getViewports()[0];+ this._usable$.next(Boolean(skeleton && scene));}getSelectionDataWithStyle(): ISelectionWithCoordAndStyle[] {