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

onCellCommit() prop causing prevCell to be null on first trigger #272

Open
burnedfaceless opened this issue Dec 28, 2022 · 1 comment
Open
Labels
bug Something isn't working

Comments

@burnedfaceless
Copy link

burnedfaceless commented Dec 28, 2022

When calling the onCellCommit() prop I am encountering an issue where the value of prevCell is null the first time onCellCommit() is triggered. On subsequent firings it works correctly. Here is my code and the output of my JavaScript console.

// changing 'Vanilla' in cell to 'Vanilla Ice Cream' and pressing enter.
prevCell:  null
nextCell:  {value: 'Vanilla Ice Cream'}
lastChanged:  {row: 0, column: 0}

// changing 'Strawberry' to 'Strawberry Ice Cream'
prevCell:  {value: 'Strawberry'}
nextCell:  {value: 'Strawberry Ice Cream'}
lastChanged:  {row: 1, column: 0}

// changing 'Chocolate' to 'Chocolate Chip Cookies'
prevCell:  {value: 'Chocolate'}
nextCell:  {value: 'Chocolate Chip Cookies'}
lastChanged:  {row: 0, column: 1}
const App = () => {

  const onCellCommit = (prevCell, nextCell, lastChanged) => {
    console.log('prevCell: ', prevCell)
    console.log('nextCell: ', nextCell)
    console.log('lastChanged: ', lastChanged)
  }

  const data = [
    [{ value: "Vanilla" }, { value: "Chocolate" }],
    [{ value: "Strawberry" }, { value: "Cookies" }],
  ]
  
  return (
    <div>
      <Spreadsheet
        onCellCommit={onCellCommit}
        data={data}
      />
    </div>
  )
}
@iddan iddan added the bug Something isn't working label Dec 30, 2022
@iddan
Copy link
Owner

iddan commented Dec 30, 2022

Thank you @burnedfaceless for the detailed report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants