{"action":"created","issue":{"url":"https://api.github.com/repos/adazzle/react-data-grid/issues/1007","repository_url":"https://api.github.com/repos/adazzle/react-data-grid","labels_url":"https://api.github.com/repos/adazzle/react-data-grid/issues/1007/labels{/name}","comments_url":"https://api.github.com/repos/adazzle/react-data-grid/issues/1007/comments","events_url":"https://api.github.com/repos/adazzle/react-data-grid/issues/1007/events","html_url":"https://github.com/adazzle/react-data-grid/issues/1007","id":270844710,"number":1007,"title":"Unintended sorting after select","user":{"login":"GenoD","id":5068500,"avatar_url":"https://avatars1.githubusercontent.com/u/5068500?v=4","gravatar_id":"","url":"https://api.github.com/users/GenoD","html_url":"https://github.com/GenoD","followers_url":"https://api.github.com/users/GenoD/followers","following_url":"https://api.github.com/users/GenoD/following{/other_user}","gists_url":"https://api.github.com/users/GenoD/gists{/gist_id}","starred_url":"https://api.github.com/users/GenoD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GenoD/subscriptions","organizations_url":"https://api.github.com/users/GenoD/orgs","repos_url":"https://api.github.com/users/GenoD/repos","events_url":"https://api.github.com/users/GenoD/events{/privacy}","received_events_url":"https://api.github.com/users/GenoD/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-11-02T23:56:45Z","updated_at":"2017-11-04T04:19:55Z","closed_at":null,"author_association":"NONE","body":"### Which version of React JS are you using?\r\n\r\n✅ Officially supported ✅\r\n- [ x] v15.4.x\r\n\r\n⚠️ Not officially supported, expect warnings ⚠️\r\n- [ ] v15.5.x\r\n- [ ] v15.6.x\r\n\r\n☣️ Not officially supported, expect warnings and errors ☣️\r\n- [ ] v16.x.x\r\n\r\n---\r\n\r\n### Which browser are you using?\r\n\r\n✅ Officially supported ✅\r\n- [ ] IE 9 / IE 10 / IE 11\r\n- [ ] Edge\r\n- [x ] Chrome\r\n\r\n⚠️ Not officially supported, but \"should work\" ⚠️\r\n- [x ] Firefox\r\n- [ ] Safari\r\n\r\n---\r\n\r\n### I'm submitting a ...\r\n\r\n- [ x] 🐛 Bug Report\r\n- [ ] 💡 Feature Request\r\n\r\n> 👋 Need general support? Not sure about how to use React itself, or how to get started with the Grid?\r\n> Please do not submit support request here. Instead see\r\n\r\n> https://github.com/adazzle/react-data-grid/blob/master/CONTRIBUTING.md\r\n\r\n---\r\n\r\n### Issue Details\r\n\r\nPlease include:\r\n- What the current behavior is\r\nUnintended sorting of grid occurs after checkbox select while a \"SortDirection\" is applied. Seems to only apply to groups with matching keys values for the sorted column. \r\n\r\n    \r\n           \r\n![sorting bug](https://user-images.githubusercontent.com/5068500/32355686-6f6b86d0-bfed-11e7-994b-8eccb8d973bd.gif)\r\n\r\n\r\nE.x \"A&F\" are switching places after each click. \r\n\r\n- What the desired behvaior is\r\nGrid should not change order of rows with matching key values in sorted column.\r\n\r\n- (If Bug) Steps to reproduce the issue\r\nRefer to GIF\r\n(Although seems to only occur after selecting a row. Deselecting does not modify row ordering)\r\n\r\nWe especially love screenshots / videos of problems, and remember\r\nThe Best Issue Is A Pull Request™\r\n\r\n\r\nRelavant code:\r\n```\r\n<ReactDataGrid\r\n       rowKey='PurchaseOrder_id'\r\n       enableCellSelect={true}\r\n       onGridSort={handleGridSort}\r\n       columns={columns}\r\n       rowGetter={rowGetter}\r\n       rowsCount={getSize() }\r\n       enableRowSelect='single'\r\n       rowSelection={{\r\n         showCheckbox: true,\r\n         onRowsSelected: onRowsSelected,\r\n         onRowsDeselected: onRowsDeselected,\r\n         selectBy: {\r\n         isSelectedKey: 'isSelected'\r\n      }\r\n    }}\r\n    onRowClick={onRowClick}\r\n    onCellSelected={onCellSelected}\r\n/>\r\n\r\n\r\nconst onRowsSelected = (rows) => {\r\n    let newRows = getRows();\r\n    let selectedRows = [newRows[rows[0].rowIdx]];\r\n    newRows.map(r => {\r\n      r.isSelected = false;\r\n    });\r\n    rows.map(r => {\r\n      newRows[r.rowIdx].isSelected = true;\r\n    });\r\n    this.setState({ rows: newRows, selectedRows: selectedRows });\r\n}\r\n\r\nconst onRowsDeselected = (rows) => {\r\n    let rowIndexes = rows.map(r => r.rowIdx);\r\n    let newRows = [...this.state.rows];\r\n    rows.map (r => {\r\n      newRows[r.rowIdx].isSelected = false;\r\n    });\r\n    this.setState({ rows: newRows, selectedRows: [] });\r\n}\r\n\r\nconst handleGridSort = (sortColumn, sortDirection) => {\r\n    var state = Object.assign({}, this.state, { sortColumn: sortColumn, sortDirection: sortDirection });\r\n    this.setState(state);\r\n}\r\n\r\nconst getRows = () => {\r\n    return Data.Selectors.getRows(this.state);\r\n}\r\n\r\nconst getSize = () => {\r\n    return getRows().length;\r\n}\r\n\r\nconst rowGetter = rowIdx => {\r\n    var rows = getRows();\r\n    return rows[rowIdx];\r\n}\r\n\r\nconst columns = [\r\n  {\r\n      key: 'Num',\r\n      name: <Translate value=\"po_no\"/>,\r\n      resizable: true,\r\n      sortable: true,\r\n      width: 100,\r\n      filterable: true\r\n  },\r\n  {\r\n      key: 'VendorID',\r\n      name: <Translate value=\"vendor_no\"/>,\r\n      resizable: true,\r\n      sortable: true,\r\n      width: 100,\r\n      filterable: true\r\n  },"},"comment":{"url":"https://api.github.com/repos/adazzle/react-data-grid/issues/comments/341870754","html_url":"https://github.com/adazzle/react-data-grid/issues/1007#issuecomment-341870754","issue_url":"https://api.github.com/repos/adazzle/react-data-grid/issues/1007","id":341870754,"user":{"login":"GenoD","id":5068500,"avatar_url":"https://avatars1.githubusercontent.com/u/5068500?v=4","gravatar_id":"","url":"https://api.github.com/users/GenoD","html_url":"https://github.com/GenoD","followers_url":"https://api.github.com/users/GenoD/followers","following_url":"https://api.github.com/users/GenoD/following{/other_user}","gists_url":"https://api.github.com/users/GenoD/gists{/gist_id}","starred_url":"https://api.github.com/users/GenoD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GenoD/subscriptions","organizations_url":"https://api.github.com/users/GenoD/orgs","repos_url":"https://api.github.com/users/GenoD/repos","events_url":"https://api.github.com/users/GenoD/events{/privacy}","received_events_url":"https://api.github.com/users/GenoD/received_events","type":"User","site_admin":false},"created_at":"2017-11-04T04:19:55Z","updated_at":"2017-11-04T04:19:55Z","author_association":"NONE","body":"@kamaldlk Sorry I did not include that line earlier. I have checked and the Product_id's of the rows are unique, yet the rows keep moving "}}
{"actor":{"display_login":"GenoD"}}