Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Regression fix multi table typing#468

Merged
Marc-Andre-Rivet merged 7 commits into
masterfrom
regression-fix-multi-table-typing
Jun 17, 2019
Merged

Regression fix multi table typing#468
Marc-Andre-Rivet merged 7 commits into
masterfrom
regression-fix-multi-table-typing

Conversation

@Marc-Andre-Rivet

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

Copy link
Copy Markdown
Contributor

#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
Comment thread demo/App.tsx

return (<DataTable
{...props}
/>);

Copy link
Copy Markdown
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.

Comment thread demo/App.tsx

import './style.less';

class App extends Component<any, any> {

Copy link
Copy Markdown
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.

}

const sanitizedProps = sanitizeProps(this.props);
const sanitizedProps = this.sanitizer.sanitize(this.props);

Copy link
Copy Markdown
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

Comment thread src/dash-table/dash/Sanitizer.ts Outdated

private static readonly applyDefaultToLocale = memoizeOne(applyDefaultToLocale);

private static readonly applyDefaultsToColumns = memoizeOne(applyDefaultsToColumns);

Copy link
Copy Markdown
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.

});
});
});

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

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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
Copy Markdown
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

@alexcjohnson alexcjohnson left a comment

Copy link
Copy Markdown
Collaborator

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! 💃

Marc-André Rivet added 2 commits June 17, 2019 09:20
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