Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Regression fix multi table typing #468

Merged
merged 7 commits into from
Jun 17, 2019

Conversation

Marc-Andre-Rivet
Copy link
Contributor

@Marc-Andre-Rivet Marc-Andre-Rivet commented Jun 14, 2019

#446 introduced a regression in the table sanitation logic causing a memoized functions to be shared across tables, resulting in an infinite loop re-rendering of all tables involve.

Marc-André Rivet added 2 commits June 13, 2019 19:14
- revert sanitizer to failing impl
- app.js -> tsx
@chriddyp chriddyp temporarily deployed to dash-table-review-pr-468 June 14, 2019 18:36 Inactive

return (<DataTable
{...props}
/>);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two tables mode: shallow copy each prop & memoize -- feed the 2nd table with these new values.


import './style.less';

class App extends Component<any, any> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renaming to .tsx file but mostly just filling in with any. Can improve some more later. At least now it's TS too.

}

render() {
if (!isValidProps(this.props)) {
return (<div>Invalid props combination</div>);
}

const sanitizedProps = sanitizeProps(this.props);
const sanitizedProps = this.sanitizer.sanitize(this.props);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each table instance has its sanitizer instance


private static readonly applyDefaultToLocale = memoizeOne(applyDefaultToLocale);

private static readonly applyDefaultsToColumns = memoizeOne(applyDefaultsToColumns);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static readonly on purpose to see the tests fail for this mode. This is essentially equivalent to the previous implementation. Will make readonly once a test run fails to demonstrate the impact.

});
});
});

Copy link
Contributor Author

@Marc-Andre-Rivet Marc-Andre-Rivet Jun 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subset of edit tests that are known to be impacted by the presence of a second table.

Pulled out from the tests below and applied to one more flavor.

it('can edit when clicking outside of cell', () => {
DashTable.getCell(0, 1).click();
DOM.focused.type(`abc`);
cy.wait(1000);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The delay is not great but need to guarantee the table has had time to re-render if stuck in a loop.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm OK. I guess if it's an async system causing the infinite loop that makes sense. Please put a comment by each of these waits referencing this PR so we know why it's there and we don't try to optimize it away later, since presumably the test will still pass if it were removed - it just wouldn't be testing what it's supposed to be testing.

@chriddyp chriddyp temporarily deployed to dash-table-review-pr-468 June 14, 2019 18:43 Inactive
@chriddyp chriddyp temporarily deployed to dash-table-review-pr-468 June 14, 2019 18:45 Inactive
@chriddyp chriddyp temporarily deployed to dash-table-review-pr-468 June 14, 2019 18:56 Inactive
@Marc-Andre-Rivet Marc-Andre-Rivet marked this pull request as ready for review June 14, 2019 19:04
Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic detective work. Just one little request for comments then this is good to go! 💃

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants