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

add the evaluated data on change #339

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

siliconjungle
Copy link

Haven't added the test yet - wanted to check whether this was the recommended way to make the suggested change?

@@ -1,6 +1,6 @@
{
"name": "react-spreadsheet",
"version": "0.8.4",
"name": "@silicon-jungle/fork-react-spreadsheet",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably a mistake. Must be "react-spreadsheet".

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this should not be included. I was just running this as a test. Not sure why I pushed this up. Will fix.

@@ -84,13 +84,13 @@
"rollup": "^3.20.2",
"rollup-plugin-dts": "^5.3.0",
"rollup-plugin-postcss": "^4.0.1",
"rollup-plugin-typescript2": "^0.30.0",
"rollup-plugin-typescript2": "^0.35.0",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how version bumps are handled in this package, but they're probably not needed for this feature. I'd revert this as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woops - yeah, this was accidental.

onChange?: (data: Matrix.Matrix<CellType>) => void;
onChange?: (
data: Matrix.Matrix<CellType>,
evaluatedData: Matrix.Matrix<CellType>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this change! Makes it easy to get exactly what you need.
When the API grows, it might be better to expose a single Matrix where each cell has properties like raw and evaluated along with other data in it. But that's a bit of a higher-level-decision.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I feel like merging the two data structured together would be better. Should we merge in something separate like this and merge them in together at a later date? Or should we talk about a higher-level change here?

Copy link
Owner

@iddan iddan Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I think merging them won't be necessary. It will introduce an additional performance cost that I don't think is justified.

@@ -145,7 +145,7 @@ describe("<Spreadsheet />", () => {
});
// Check onChange is called
expect(EXAMPLE_PROPS.onChange).toBeCalledTimes(1);
expect(EXAMPLE_PROPS.onChange).toBeCalledWith(EXAMPLE_MODIFIED_DATA);
// expect(EXAMPLE_PROPS.onChange).toBeCalledWith(EXAMPLE_MODIFIED_DATA);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you said, a test would be nice. Need some help? :)

@@ -101,7 +101,10 @@ export type Props<CellType extends Types.CellBase> = {
/** Callback called on key down inside the spreadsheet. */
onKeyDown?: (event: React.KeyboardEvent) => void;
/** Callback called when the Spreadsheet's data changes. */
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would love an updated doc for this prop

@@ -1873,10 +1873,10 @@
schema-utils "^3.0.0"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @Carnageous correctly pointed out, I expect the yarn.lock to not change in this PR.

@iddan
Copy link
Owner

iddan commented Sep 26, 2023

Great work @siliconjungle and thank you @Carnageous for helping with the review. I would love to merge once the fixes are in place.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 6271723049

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 80.25%

Totals Coverage Status
Change from base Build 6145886764: 0.0%
Covered Lines: 957
Relevant Lines: 1143

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants