Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: No change event is emitted when the formula changes #1408

Open
nomind2think opened this issue Apr 18, 2024 · 14 comments
Open

[Bug]: No change event is emitted when the formula changes #1408

nomind2think opened this issue Apr 18, 2024 · 14 comments
Labels
Feature Something we can add later on without introducing a breaking change

Comments

@nomind2think
Copy link

Description

when i insert/remove row, formula's relative address is change, but no valueUpdateEvent emit, how to listening this event?

    const engine = HyperFormula.buildFromArray([
      ['1', '=SUM(A1:A2)'],
      ['1'],
    ])
    engine.on('valuesUpdated', (changes)=>{console.log(changes)})
    engine.addRows(engine, 0, [1, 1])
    //==SUM(A1:A3)
    console.log(engine.getCellFormula(adr('B1')))

Video or screenshots

No response

Demo

none

HyperFormula version

2.7.0

Your framework

vue

Your environment

nodejs v18.17.1

@adrianszymanski89
Copy link
Contributor

Hi @CodeChaosConjurer

Thank you for contacting us. I tried to recreate this behavior in this example, but there seems to be something wrong: https://stackblitz.com/edit/vitejs-vite-pjjrzz?file=index.html,main.js&terminal=dev. Can you please modify it so it matches your scenario?

@nomind2think
Copy link
Author

Hi @CodeChaosConjurer

Thank you for contacting us. I tried to recreate this behavior in this example, but there seems to be something wrong: https://stackblitz.com/edit/vitejs-vite-pjjrzz?file=index.html,main.js&terminal=dev. Can you please modify it so it matches your scenario?

https://stackblitz.com/edit/stackblitz-starters-2wmbyf?file=index.js i'm create a new stack. without vite, just simple with nodejs. I want to listener formulas change event.

@adrianszymanski89
Copy link
Contributor

Hi @CodeChaosConjurer

Unfortunately, this example still doesn't work for me. However, if you need a listener, did you try this method? https://hyperformula.handsontable.com/api/interfaces/listeners.html#values

@nomind2think
Copy link
Author

Hi @CodeChaosConjurer

Unfortunately, this example still doesn't work for me. However, if you need a listener, did you try this method? https://hyperformula.handsontable.com/api/interfaces/listeners.html#values

Hi, i'm fork your stackblitz, https://stackblitz.com/edit/vitejs-vite-yhajtz?file=index.html,main.js&terminal=dev will it work?
i try to use listening valuesUpdated event,but no event emit.B1's raw formulas is =SUM(A1:A2),after insert row is =SUM(A1:A3), The value is not updated but the formula is. But no event emit.
I try to explain the steps to reproduce.
The first step is to create a sheet with a formula as a relative reference address.
The second step is to insert or delete a row that affects the expression of the formula but does not affect its value. This way there will be no valueUpdate event.

For example, the formula in cell B1 is =SUM(A1:A2). If you insert a row after the first row, the formula in B1 becomes =SUM(A1:A3), but the value of the inserted row is 0, which will not happen. Modify the value of B1, but the formula of B1 has changed and I cannot receive any events.

@adrianszymanski89
Copy link
Contributor

Hi @CodeChaosConjurer

I'm not sure if this example was updated. It throws an error that adr is not defined. Can you please check it again?

@nomind2think
Copy link
Author

Hi @CodeChaosConjurer

I'm not sure if this example was updated. It throws an error that adr is not defined. Can you please check it again?

sorry,try it again, i don't know how to run this program

@nomind2think
Copy link
Author

Hi @CodeChaosConjurer

I'm not sure if this example was updated. It throws an error that adr is not defined. Can you please check it again?

i 'm already fix it, plz try it again

@adrianszymanski89
Copy link
Contributor

Hi @CodeChaosConjurer

Thank you. Now it works. We'll take a closer look at this, and I'll get back to you when I have more information.

@nomind2think
Copy link
Author

Hi @CodeChaosConjurer

Thank you. Now it works. We'll take a closer look at this, and I'll get back to you when I have more information.

Thank you~

@adrianszymanski89
Copy link
Contributor

Hi @CodeChaosConjurer

We determined that, according to the documentation, this behavior is correct: https://hyperformula.handsontable.com/api/interfaces/listeners.html#valuesupdated

This hook is only fired on value change, not the formula, so it's the correct behavior in your case.

Here's an updated example showing that it works as expected: https://stackblitz.com/edit/vitejs-vite-ex3waj?file=index.html,main.js&terminal=dev

@nomind2think
Copy link
Author

Hi @CodeChaosConjurer

We determined that, according to the documentation, this behavior is correct: https://hyperformula.handsontable.com/api/interfaces/listeners.html#valuesupdated

This hook is only fired on value change, not the formula, so it's the correct behavior in your case.

Here's an updated example showing that it works as expected: https://stackblitz.com/edit/vitejs-vite-ex3waj?file=index.html,main.js&terminal=dev

ok,thanks,Is there any way for me to listen for formula change events?

@adrianszymanski89
Copy link
Contributor

Hi @nomind2think

Currently, there's no such method available, but this is valuable feedback and that might be a good idea to add such method in the future.

@nomind2think
Copy link
Author

Hi @nomind2think

Currently, there's no such method available, but this is valuable feedback and that might be a good idea to add such method in the future.

ok,thanks,I think this can be closed, what do you think?

@AMBudnik AMBudnik added the Feature Something we can add later on without introducing a breaking change label Apr 29, 2024
@AMBudnik
Copy link
Contributor

Hi @nomind2think we can keep it open as a feature. I've just attached the exact label this this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Something we can add later on without introducing a breaking change
Projects
None yet
Development

No branches or pull requests

3 participants