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

[Table] 'onRowSelection' does't get called with 'none' while deselecting all rows by check a single row #5964

Closed
gunx3961 opened this issue Jan 19, 2017 · 7 comments
Labels
component: table This is the name of the generic UI component, not the React module! v0.x

Comments

@gunx3961
Copy link

Problem description

error

Try checking a single row after the table has been allSelected,
the single row won't be checked but 'onRowSelection' will get called with an array, which includes the single row's key.

Link to minimally-working code that reproduces the issue

function handleSelection(arr) {
  console.log(arr);
}

const data = [
  { id: '0', name: 'zero' },
  { id: '1', name: 'one' },
  { id: '2', name: 'two' },
  { id: '3', name: 'three' },
  { id: '4', name: 'four' }
];

  render() {
    return (
      <Table
        multiSelectable
        onRowSelection={handleSelection}
        >
        <TableHeader>
          <TableRow>
            <TableHeaderColumn>id</TableHeaderColumn>
            <TableHeaderColumn>name</TableHeaderColumn>
          </TableRow>
        </TableHeader>
        <TableBody
          showRowHover
          deselectOnClickaway={false}
          >
          {data.map((row, index) => (
            <TableRow key={index}>
              <TableRowColumn>{row['id']}</TableRowColumn>
              <TableRowColumn>{row['name']}</TableRowColumn>
            </TableRow>
          ))}
        </TableBody>
      </Table>
    );
  }

Versions

  • Material-UI: 0.16.7
  • React: 15.4.2
  • Browser: Chrome 55
@NewOldMax
Copy link

I confirm same behavior on http://www.material-ui.com/#/components/table
asd15

@ArcanisCz
Copy link
Contributor

ArcanisCz commented Jan 28, 2017

And what is the desired behavior? I can imagine 2 outcomes.

Given table with rows [0,1,2,3], click to selectAll, then click on item 2.

  1. Will result with item 2 unchecked, others remain checked (checked [0,1,3])
  2. Will result with only item 2 checked (checked [2])

And then "selectAll" becomes unchecked. Checking it again will result in selecting all (it both cases)

@NewOldMax
Copy link

I expect something like this
1

@lagneshthakur
Copy link

I've raised a PR #7453 that fixes this and achieves the desired behavior.

lagneshthakur added a commit to lagneshthakur/material-ui that referenced this issue Jul 17, 2017
lagneshthakur added a commit to lagneshthakur/material-ui that referenced this issue Jul 17, 2017
@oliviertassinari
Copy link
Member

We have been porting the component on the v1-beta branch. We reimplemented it from the ground-up. While we haven't tested it, I think that the issue is most likely fixed on that branch. Hence, I'm closing it.
Still, we will accept PR fixes until v1-beta takes over the master branch.

@oliviertassinari oliviertassinari added component: table This is the name of the generic UI component, not the React module! v0.x labels Sep 11, 2017
@rdsedmundo
Copy link

rdsedmundo commented Aug 30, 2018

Did this ever get a fix on 0.x branch? Facing this problem on a legacy app that upgrading for the 1.x is not a viable option for now.

@oliviertassinari
Copy link
Member

@rdsedmundo No, it wasn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: table This is the name of the generic UI component, not the React module! v0.x
Projects
None yet
Development

No branches or pull requests

6 participants