Skip to content

[Bug]: FORMULATEXT is not recalculated when the referenced cell's formula changes #1744

Description

@sl01k

Description

FORMULATEXT returns a stale result after the formula in the referenced cell is changed via setCellContents. The cell containing FORMULATEXT is not recalculated — even though the value of the referenced cell changed as well — and it is not included in the exported changes array.

Steps to reproduce

const { HyperFormula } = require('hyperformula');

const hf = HyperFormula.buildFromArray(
  [[1, '=A1', '=FORMULATEXT(B1)']],
  { licenseKey: 'gpl-v3' }
);

hf.getSheetValues(0); // [[1, 1, '=A1']] — OK

// Change the formula in B1 from =A1 to =A1+1
const changes = hf.setCellContents({ sheet: 0, col: 1, row: 0 }, '=A1+1');

console.log(changes);
// [{ address: { sheet: 0, row: 0, col: 1 }, newValue: 2 }]
// → only B1 is reported; C1 is missing from the changes array

hf.getCellValue({ sheet: 0, col: 2, row: 0 });
// actual:   '=A1'
// expected: '=A1+1'

Expected behavior

C1 should be recalculated and return '=A1+1', and the change to C1 should be included in the array returned by setCellContents (so that integrations consuming exported changes — e.g. the Handsontable Formulas plugin — can re-render it).

Actual behavior

C1 keeps returning the old formula text '=A1' untilthat B1's value also changed here (1 → 2), so this doesn't look like the usual "value didn't change, so dependents are skipped" optimization — the FORMULATEXT vertex simply never gets
marked for recomputation. This is possibly related tol function (doesNotNeedArgumentsToBeComputed: true), so its dependency on the referenced cell may not be registered in the dependency graph correctly.

Related reports

Demo: https://demos.handsontable.com/share/3x2x291w19

Video or screenshots

No response

Demo

https://demos.handsontable.com/share/3x2x291w19

HyperFormula version

3.4.0

Your framework

React

Your environment

Chrome 151, macOS Tahoe 26

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions