Skip to content

Commit

Permalink
Synced code with develop #7031
Browse files Browse the repository at this point in the history
  • Loading branch information
wszymanski committed Sep 23, 2021
2 parents 6bb854a + 102b3bc commit f6dac72
Show file tree
Hide file tree
Showing 6 changed files with 583 additions and 61 deletions.
7 changes: 7 additions & 0 deletions .changelogs/8078.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"title": "Fixed multiple bugs related to undo/redo actions while using the Formulas plugin",
"type": "fixed",
"issue": 8078,
"breaking": false,
"framework": "none"
}
4 changes: 0 additions & 4 deletions src/plugins/autofill/__tests__/autofill.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,6 @@ describe('AutoFill', () => {
};

const direction = 'down';
const hasFillDataChanged = false;

expect(afterAutofill).toHaveBeenCalledWith(
fillData,
Expand All @@ -574,7 +573,6 @@ describe('AutoFill', () => {
new CellCoords(targetRange.to.row, targetRange.to.col),
),
direction,
hasFillDataChanged,
);
});

Expand Down Expand Up @@ -633,7 +631,6 @@ describe('AutoFill', () => {
};

const direction = 'down';
const hasFillDataChanged = true;

expect(afterAutofill).toHaveBeenCalledWith(
fillData,
Expand All @@ -648,7 +645,6 @@ describe('AutoFill', () => {
new CellCoords(targetRange.to.row, targetRange.to.col),
),
direction,
hasFillDataChanged,
);
});

Expand Down
17 changes: 1 addition & 16 deletions src/plugins/autofill/autofill.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { BasePlugin } from '../base';
import Hooks from '../../pluginHooks';
import { offset, outerHeight, outerWidth } from '../../helpers/dom/element';
import { arrayEach, arrayMap } from '../../helpers/array';
import { isObjectEqual } from '../../helpers/object';
import EventManager from '../../eventManager';
import { CellCoords, CellRange } from '../../3rdparty/walkontable/src';
import { getDeltas, getDragDirectionAndRange, DIRECTIONS, getMappedFillHandleSetting } from './utils';
Expand Down Expand Up @@ -235,7 +234,6 @@ export class Autofill extends BasePlugin {

if (startOfDragCoords && startOfDragCoords.row > -1 && startOfDragCoords.col > -1) {
const selectionData = this.getSelectionData();

const sourceRange = selectionRangeLast.clone();
const targetRange = new CellRange(startOfDragCoords, startOfDragCoords, endOfDragCoords);

Expand All @@ -254,19 +252,6 @@ export class Autofill extends BasePlugin {
return false;
}

// TODO: The `hasFillDataChanged` hook argument allows skipping processing of the autofill
// handler when the user modifies the fillData in the `beforeAutofill` hook. The workaround
// is necessary for the Formulas plugin and can be removed after implementing the missing
// feature for the HF (such as `getFillRangeData` method). With that the last argument could
// be removed from the `afterAutofill` hook.
const {
from: sourceFrom,
to: sourceTo,
} = sourceRange;

const refData = this.hot.getData(sourceFrom.row, sourceFrom.col, sourceTo.row, sourceTo.col);

const hasFillDataChanged = !isObjectEqual(refData, beforeAutofillHookResult);
const deltas = getDeltas(startOfDragCoords, endOfDragCoords, selectionData, directionOfDrag);

let fillData = beforeAutofillHookResult;
Expand Down Expand Up @@ -314,7 +299,7 @@ export class Autofill extends BasePlugin {
);

this.setSelection(cornersOfSelectionAndDragAreas);
this.hot.runHooks('afterAutofill', fillData, sourceRange, targetRange, directionOfDrag, hasFillDataChanged);
this.hot.runHooks('afterAutofill', fillData, sourceRange, targetRange, directionOfDrag);
this.hot.render();

} else {
Expand Down
Loading

0 comments on commit f6dac72

Please sign in to comment.