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

[9.0.0] Can't block autofill via beforeChange when using formulas #8107

Closed
AMBudnik opened this issue May 26, 2021 · 10 comments
Closed

[9.0.0] Can't block autofill via beforeChange when using formulas #8107

AMBudnik opened this issue May 26, 2021 · 10 comments
Assignees
Labels
Auto fill Plugin bug Formulas Plugin Regression Issues that were created while adding new changes to the source code Status: Released

Comments

@AMBudnik
Copy link
Contributor

AMBudnik commented May 26, 2021

Description

We are not able to block autofill when formulas are defined.

The issue should be fixed after handsontable/hyperformula#678

The issue does not occur when

Steps to reproduce

  1. Autofill A1 to A2

Result in v8.4.0 and v9 without formulas
Cell A2 does not change its value - we still have 2017 in the cell.

Result in v9 with formulas enabled
Cell A2 changes its value - we have 2016 in the cell.

Demo

https://jsfiddle.net/xc5gqLn1/4/

Your environment

  • Handsontable version: v9+
  • Browser Name and version: Chrome 89
  • Operating System: Windows 10

Test Zen 26993 after fix

@AMBudnik AMBudnik added bug Auto fill Plugin Formulas Plugin Regression Issues that were created while adding new changes to the source code Blocked Issue that is being blocked by another one or an epic labels May 26, 2021
@Siemienik
Copy link
Contributor

Actually, Enabling the HyperFormula causes that we cannot prevent change the value:

With HF:
May-28-2021 08-51-08

Without:
May-28-2021 08-51-27

const container = document.getElementById('container');
    const hot = new Handsontable(container, {
      data: [
        [1, 999, 3, '=B1*500', '=B1*5'],
        [9, 8, 7, '=B2*500', '=B2*5'],
        [4, 6, 2, '=B3*500', '=B3*5'],
      ],
      type: 'numeric',
      rowHeaders: true,
      colHeaders: true,
      // formulas: {
      //   engine: HyperFormula
      // },
      beforeChange(changes, source) {
        changes[0] = null;
      }
    });

@Siemienik Siemienik changed the title [9.0.0] We are not able to block autofill when formulas are defined [9.0.0] We are not able to block cell value update when formulas are defined May 28, 2021
@rsify rsify self-assigned this May 31, 2021
@rsify
Copy link
Contributor

rsify commented May 31, 2021

The problem seems to be related to the fact that we're hooking up to beforeChange in the formulas plugin, the callback to which will always run before any user defined hook. It used to be the case that the plugin used to work with modifyData instead before e8a8249, and it seems like the bug above didn't exist before that commit.

@rsify
Copy link
Contributor

rsify commented May 31, 2021

#8134

@rsify
Copy link
Contributor

rsify commented Jul 7, 2021

Looks like the problem described in #8107 (comment) was fixed in #8139, I'm changing the title back to the original one related to autofill only.

@rsify rsify changed the title [9.0.0] We are not able to block cell value update when formulas are defined [9.0.0] Can't block autofill via beforeChange when using formulas Jul 7, 2021
@wojciechczerniak
Copy link
Contributor

@nikersify Isn't it fixed in #8129?

@rsify
Copy link
Contributor

rsify commented Jul 7, 2021

@wojciechczerniak I get an error every time I try to autofill using the latest build from that PR (0053371) 🤷

@rsify
Copy link
Contributor

rsify commented Jul 7, 2021

@wojciechczerniak never mind, I tested the commit (fecc19b) before the one that prepares for hyperformula@1.0 (60594b5) - I don't get an error anymore but this issue is not fixed by those changes.

@wojciechczerniak
Copy link
Contributor

Ok. So this is a first good step, we will have data in beforeChange from HF, but we still use beforeChange to sync the changes with HF

rsify added a commit that referenced this issue Aug 31, 2021
jansiegel added a commit that referenced this issue Sep 16, 2021
* upgrade hyperformula to 1.1.0

* changelog entry

* set `useArrayArithmetic` to `true`

* use hf's built-in `doesCellHaveFormula`

* remove `attempt` from `getCellType`

* Update .changelogs/8502.json

Co-authored-by: kirszenbaum <jakub.wisniewski@handsontable.com>

* remove `attempt` from `isFormulaCellType` calls

* refactor `onBeforeAutofill`

Co-Authored-By: jansiegel <jansiegel@users.noreply.github.com>

* add a test for #8057

* add a test for #8107

* add changelogs [skip ci]

* - Get rid of the 'attempt' helper function
- Fix some problems with destroyed HF's instance being called and other minor issues

* Remove leftover 'Infinity' mentions.

Co-authored-by: kirszenbaum <jakub.wisniewski@handsontable.com>
Co-authored-by: jansiegel <jansiegel@users.noreply.github.com>
Co-authored-by: Jan Siegel <js.ziggle@gmail.com>
@aninde
Copy link
Contributor

aninde commented Sep 29, 2021

This issue will be fixed by v10 https://jsfiddle.net/9h0soLvu/.

@AMBudnik AMBudnik added Status: Released and removed Blocked Issue that is being blocked by another one or an epic labels Sep 29, 2021
@AMBudnik
Copy link
Contributor Author

Issue closed as fixed in v10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto fill Plugin bug Formulas Plugin Regression Issues that were created while adding new changes to the source code Status: Released
Projects
None yet
Development

No branches or pull requests

5 participants