diff --git a/packages/engine-formula/src/services/dependency-manager.service.ts b/packages/engine-formula/src/services/dependency-manager.service.ts index c64dc50f9f6..a5411ca919d 100644 --- a/packages/engine-formula/src/services/dependency-manager.service.ts +++ b/packages/engine-formula/src/services/dependency-manager.service.ts @@ -289,26 +289,6 @@ export class DependencyManagerService extends Disposable implements IDependencyM child?.parents.delete(shouldBeClearTree.treeId); } - const parentsArray: FormulaDependencyTree[] = []; - const childrenArray: FormulaDependencyTree[] = []; - - for (const parentTreeId of parents) { - const parent = allTreeMap.get(parentTreeId); - if (parent) { - parentsArray.push(parent); - } - } - - for (const childTreeId of children) { - const child = allTreeMap.get(childTreeId); - if (child) { - childrenArray.push(child); - } - } - - this._buildDependencyTree(parentsArray, childrenArray); - this._buildReverseDependency(parentsArray, childrenArray); - shouldBeClearTree.dispose(); } diff --git a/packages/engine-formula/src/services/runtime.service.ts b/packages/engine-formula/src/services/runtime.service.ts index d48bef80aee..7523de25dd6 100644 --- a/packages/engine-formula/src/services/runtime.service.ts +++ b/packages/engine-formula/src/services/runtime.service.ts @@ -461,12 +461,12 @@ export class FormulaRuntimeService extends Disposable implements IFormulaRuntime const arrayFormulaRange = this._unitArrayFormulaRange[unitId]!; - let arrayData = new ObjectMatrix(); - - if (arrayFormulaRange[sheetId]) { - arrayData = new ObjectMatrix(arrayFormulaRange[sheetId]); + if (arrayFormulaRange[sheetId] === null || arrayFormulaRange[sheetId] === undefined) { + arrayFormulaRange[sheetId] = {}; } + const arrayData = new ObjectMatrix(arrayFormulaRange[sheetId]); + if (this._runtimeArrayFormulaCellData[unitId] === undefined) { this._runtimeArrayFormulaCellData[unitId] = {}; } @@ -522,10 +522,9 @@ export class FormulaRuntimeService extends Disposable implements IFormulaRuntime endColumn: endColumn - startColumn + column, }; + // Do not use getData to synchronize arrayData to arrayFormulaRange[sheetId] anymore, they are already linked, otherwise it will cause performance issues arrayData.setValue(row, column, arrayRange); - arrayFormulaRange[sheetId] = arrayData.getData(); - if ( this._checkIfArrayFormulaRangeHasData(unitId, sheetId, row, column, arrayRange) || this._checkIfArrayFormulaExceeded(rowCount, columnCount, arrayRange) diff --git a/packages/sheets-formula/src/controllers/trigger-calculation.controller.ts b/packages/sheets-formula/src/controllers/trigger-calculation.controller.ts index cf8130da13e..ad74ba07c55 100644 --- a/packages/sheets-formula/src/controllers/trigger-calculation.controller.ts +++ b/packages/sheets-formula/src/controllers/trigger-calculation.controller.ts @@ -299,13 +299,15 @@ export class TriggerCalculationController extends Disposable { this.disposeWithMe( - // eslint-disable-next-line max-lines-per-function + // eslint-disable-next-line max-lines-per-function, complexity this._commandService.onCommandExecuted((command: ICommandInfo) => { if (command.id === SetFormulaCalculationStartMutation.id) { const { forceCalculation } = command.params as ISetFormulaCalculationStartMutation; if (forceCalculation) { this._forceCalculating = true; } + } else if (command.id === SetFormulaCalculationStopMutation.id) { + this.clearProgress(); } if (command.id !== SetFormulaCalculationNotificationMutation.id) { @@ -359,8 +361,6 @@ export class TriggerCalculationController extends Disposable { break; case FormulaExecutedStateType.STOP_EXECUTION: result = 'The execution of the formula has been stopped'; - // this._executingCommandQueue = []; - this.clearProgress(); calculationProcessCount = 0; break; case FormulaExecutedStateType.SUCCESS: diff --git a/packages/ui/src/components/progress-bar/ProgressBar.tsx b/packages/ui/src/components/progress-bar/ProgressBar.tsx index 58cc3990719..27bff5714fd 100644 --- a/packages/ui/src/components/progress-bar/ProgressBar.tsx +++ b/packages/ui/src/components/progress-bar/ProgressBar.tsx @@ -37,18 +37,30 @@ export function ProgressBar(props: IProgressBarProps) { // Introduce a state variable for visibility const [visible, setVisible] = useState(count > 0); + const [prevCount, setPrevCount] = useState(0); + const [prevDone, setPrevDone] = useState(0); + useEffect(() => { if (!progressBarInnerRef.current) return; const progressBarInner = progressBarInnerRef.current; + // Hide immediately if both count and done are zero + if (count === 0 && done === 0) { + setVisible(false); + } + // Handle the special case if count and done are equal for the first time and not from a previous progress change + else if (count === done && prevCount === 0 && prevDone === 0) { + setVisible(true); + progressBarInner.style.width = '0%'; + requestAnimationFrame(() => { + progressBarInner.style.width = '100%'; + }); + } // Update the width of the progress bar - if (count > 0) { + else if (count > 0) { setVisible(true); progressBarInner.style.width = `${Math.floor((done / count) * 100)}%`; - } else if (count === 0 && done === 0) { - // Hide immediately if both count and done are zero - setVisible(false); } // Else, wait for the transition to end before hiding @@ -70,6 +82,10 @@ export function ProgressBar(props: IProgressBarProps) { progressBarInner.addEventListener('transitionend', handleTransitionEnd); + // Update prevCount and prevDone + setPrevCount(count); + setPrevDone(done); + // Clean up the event listener on unmount or when dependencies change return () => { progressBarInner.removeEventListener('transitionend', handleTransitionEnd);