Skip to content

Commit

Permalink
fix(formula): init trigger calculation controller on rendered
Browse files Browse the repository at this point in the history
  • Loading branch information
Dushusir committed Nov 21, 2024
1 parent bf8329f commit 59f455e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import type { Dependency } from '@univerjs/core';
import { DependentOn, Inject, Injector, Plugin, touchDependencies, UniverInstanceType } from '@univerjs/core';
import { TriggerCalculationController } from '@univerjs/sheets-formula';

import { IUniFormulaService, UniverDocUniFormulaPlugin } from '@univerjs/uni-formula';
import { DOC_FORMULA_UI_PLUGIN_NAME } from './const';
Expand Down Expand Up @@ -53,7 +52,6 @@ export class UniverDocUniFormulaUIPlugin extends Plugin {
override onReady(): void {
touchDependencies(this._injector, [
[IUniFormulaService],
[TriggerCalculationController],
]);
}

Expand Down
9 changes: 8 additions & 1 deletion packages/sheets-formula/src/sheets-formula.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class UniverSheetsFormulaPlugin extends Plugin {
[UpdateDefinedNameController],
]);

// The nodejs environment needs to be initialized, otherwise it has been initialized in FormulaUIController
// There is no rendering in the nodejs environment, so initialize it here
if (isNodeEnv()) {
touchDependencies(this._injector, [
[TriggerCalculationController],
Expand All @@ -137,5 +137,12 @@ export class UniverSheetsFormulaPlugin extends Plugin {
touchDependencies(this._injector, [
[DefinedNameController],
]);

// Wait for rendering to complete before initializing formula calculation
if (!isNodeEnv()) {
touchDependencies(this._injector, [
[TriggerCalculationController],
]);
}
}
}

0 comments on commit 59f455e

Please sign in to comment.