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

InMemoryTable - Cannot read property 'sortable' of undefined when columns change #1886

Closed
PhaedrusTheGreek opened this issue Apr 25, 2019 · 1 comment · Fixed by #1972
Closed
Labels

Comments

@PhaedrusTheGreek
Copy link
Contributor

PhaedrusTheGreek commented Apr 25, 2019

EUI: 6.10.7

Simultaneously changing the sort and the columns results in error: Cannot read property 'sortable' of undefined

To reproduce:

class App extends React.Component {

   store = [
    {
      'firstName': 'Shay',
      'lastName': 'Banon'
    }
  ]

   columns = [{
    field: 'firstName',
    name: 'First Name',
    sortable: true,
    truncateText: true,
  }];

   sorting = {
    sort: {
      field: 'firstName',
      direction: 'desc',
    }
  };

   handleClick = (e) => {
    this.columns = [{
      field: 'lastName',
      name: 'Last Name',
      truncateText: true,
     }
    ]

    this.sorting = {
      sort: {
        field: 'lastName',
        direction: 'desc',
      }
    };

    this.setState({})
    
  }

  render() {

  return (
    <EuiPage>
    <EuiPageBody>
      <EuiPageContent verticalPosition="center" horizontalPosition="center">
        <EuiPageContentHeader>
          <EuiPageContentHeaderSection>
            <EuiTitle>
            <a href="/#" onClick={this.handleClick}>
              Click me
            </a>
            </EuiTitle>
          </EuiPageContentHeaderSection>
        </EuiPageContentHeader>
        <EuiPageContentBody>
        <EuiInMemoryTable
          items={this.store}
          columns={this.columns}
          pagination={true}
          sorting={this.sorting}
        />
        </EuiPageContentBody>
      </EuiPageContent>
    </EuiPageBody>
  </EuiPage>
  
  )};    

  
}
@PhaedrusTheGreek
Copy link
Contributor Author

There's two ways to trigger this:

  • Set this.sorting then remove the sorted column
  • Manually set the sorted column in the UI and then remove the sorted column

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