{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/fixed-data-table/issues/145","labels_url":"https://api.github.com/repos/facebook/fixed-data-table/issues/145/labels{/name}","comments_url":"https://api.github.com/repos/facebook/fixed-data-table/issues/145/comments","events_url":"https://api.github.com/repos/facebook/fixed-data-table/issues/145/events","html_url":"https://github.com/facebook/fixed-data-table/pull/145","id":79285958,"number":145,"title":"Fix issue where table doesn't render rows when relaxing filter with zero results","user":{"login":"mikestead","id":56844,"avatar_url":"https://avatars.githubusercontent.com/u/56844?v=3","gravatar_id":"","url":"https://api.github.com/users/mikestead","html_url":"https://github.com/mikestead","followers_url":"https://api.github.com/users/mikestead/followers","following_url":"https://api.github.com/users/mikestead/following{/other_user}","gists_url":"https://api.github.com/users/mikestead/gists{/gist_id}","starred_url":"https://api.github.com/users/mikestead/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikestead/subscriptions","organizations_url":"https://api.github.com/users/mikestead/orgs","repos_url":"https://api.github.com/users/mikestead/repos","events_url":"https://api.github.com/users/mikestead/events{/privacy}","received_events_url":"https://api.github.com/users/mikestead/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/fixed-data-table/labels/CLA%20Signed","name":"CLA Signed","color":"009900"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-22T04:52:44Z","updated_at":"2015-05-22T22:32:36Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/facebook/fixed-data-table/pulls/145","html_url":"https://github.com/facebook/fixed-data-table/pull/145","diff_url":"https://github.com/facebook/fixed-data-table/pull/145.diff","patch_url":"https://github.com/facebook/fixed-data-table/pull/145.patch"},"body":"This issue only presents when you attempt to scroll to row 0 via `scrollToRow` when there's no rows. This could be seen as a misuse of the `scrollToRow` parameter, if so feel free to close.\r\n\r\n#### Steps to reproduce\r\n1. Populate a table with some content, but *not* enough for the scroll bar to appear.\r\n1. Apply a filter which removes all rows, at the same time scroll to row 0.\r\n1. Remove the filter again.\r\n\r\n#### Expected\r\nThe results displayed during step 1 should be displayed again.\r\n\r\n#### Actual\r\nNo results rendered.\r\n\r\n#### Cause\r\nIt stems from an `NaN` target scroll position making its way into `FixedDataTableScrollHelper.scrollTo`, called from `scrollToRow`, when there are no rows to render. This `NaN` value is then stored in `this._position` which causes the table not to update when there are rows to render again (minus the scroll bar).\r\n\r\nIn `scrollToRow` the line: `rowIndex = clamp(0, rowIndex, this._rowCount - 1);` returns -1 when there's no rows (max ends up less than min in the clamp) , which triggers a subsequent lookup to return `undefined`. I did try keeping the index a 0 in this case but that led to other issues.\r\n\r\n#### Fix\r\nI've put a check in `scrollToRow` to ensure we only ever scroll to 0 when there's no rows, which seems to do the trick. Or simply don't set the `scrollToRow` parameter when there's no rows!"},"comment":{"url":"https://api.github.com/repos/facebook/fixed-data-table/issues/comments/104789492","html_url":"https://github.com/facebook/fixed-data-table/pull/145#issuecomment-104789492","issue_url":"https://api.github.com/repos/facebook/fixed-data-table/issues/145","id":104789492,"user":{"login":"mikestead","id":56844,"avatar_url":"https://avatars.githubusercontent.com/u/56844?v=3","gravatar_id":"","url":"https://api.github.com/users/mikestead","html_url":"https://github.com/mikestead","followers_url":"https://api.github.com/users/mikestead/followers","following_url":"https://api.github.com/users/mikestead/following{/other_user}","gists_url":"https://api.github.com/users/mikestead/gists{/gist_id}","starred_url":"https://api.github.com/users/mikestead/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikestead/subscriptions","organizations_url":"https://api.github.com/users/mikestead/orgs","repos_url":"https://api.github.com/users/mikestead/repos","events_url":"https://api.github.com/users/mikestead/events{/privacy}","received_events_url":"https://api.github.com/users/mikestead/received_events","type":"User","site_admin":false},"created_at":"2015-05-22T22:32:36Z","updated_at":"2015-05-22T22:32:36Z","body":"Apologies, I missed out the key fact that on each refresh of the table, as the user types their filter, I set `scrollToRow={0}`. I want to ensure they see the start of the table if they've previously scrolled.\r\n\r\nI can fix this issue by not scrolling to row 0 if there's no rows, doh. That seems reasonable.  You may want to include this fix to safeguard this mistake. Feel free to close if not."}}