Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Clicking on a link in a Markdown cell now requires a single click instead of two
- Links in Markdown cells now open a new tab (target="_blank")

### Fixed
- [#785](https://github.com/plotly/dash-table/pull/785) Fix a bug where the table does not refresh correctly if a property was previously missing

## [4.7.0] - 2020-05-05
### Added
- [#729](https://github.com/plotly/dash-table/pull/729) Improve conditional styling
Expand Down
10 changes: 3 additions & 7 deletions src/dash-table/components/Table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ import 'react-select/dist/react-select.css';
import './Table.less';
import './style';
import './Dropdown.css';
import { isEqual } from 'core/comparer';
import { SingleColumnSyntaxTree } from 'dash-table/syntax-tree';
import derivedFilterMap from 'dash-table/derived/filter/map';

import controlledPropsHelper from './controlledPropsHelper';
import derivedPropsHelper from './derivedPropsHelper';
import DOM from 'core/browser/DOM';

const DERIVED_REGEX = /^derived_/;
import shouldComponentUpdate from './shouldComponentUpdate';

export default class Table extends Component<SanitizedAndDerivedProps, StandaloneState> {
constructor(props: SanitizedAndDerivedProps) {
Expand Down Expand Up @@ -94,10 +92,7 @@ export default class Table extends Component<SanitizedAndDerivedProps, Standalon
const props: any = this.props;
const state: any = this.state;

return R.any(key =>
!DERIVED_REGEX.test(key) && props[key] !== nextProps[key],
R.keysIn(props)
) || !isEqual(state, nextState);
return shouldComponentUpdate(props, nextProps, state, nextState);
}

render() {
Expand Down Expand Up @@ -159,3 +154,4 @@ export default class Table extends Component<SanitizedAndDerivedProps, Standalon
private readonly controlledPropsHelper = controlledPropsHelper();
private readonly updateDerivedProps = derivedPropsHelper();
}

14 changes: 14 additions & 0 deletions src/dash-table/components/Table/shouldComponentUpdate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import * as R from 'ramda';
import { isEqual } from 'core/comparer';

const DERIVED_REGEX = /^derived_/;

export default (
props: any,
nextProps: any,
state: any,
nextState: any
) => R.any(
key => !DERIVED_REGEX.test(key) && props[key] !== nextProps[key],
R.keysIn({ ...props, ...nextProps })
) || !isEqual(state, nextState);
27 changes: 27 additions & 0 deletions tests/cypress/tests/unit/table_update_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import shouldComponentUpdate from 'dash-table/components/Table/shouldComponentUpdate';

describe('shouldComponentUpdate', () => {
it('should update on undefined -> defined props', () => {
assert(shouldComponentUpdate({}, { a: 0 }, {}, {}));
});

it('should update on undefined -> defined state', () => {
assert(shouldComponentUpdate({}, {}, {}, { a: 0 }));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test fails without the added ...nextProps 8849e85#diff-aa707fa377faf64638e062a12fb52d85R13

});

it('should update on defined -> undefined props', () => {
assert(shouldComponentUpdate({ a: 0 }, {}, {}, {}));
});

it('should update on defined -> undefined state', () => {
assert(shouldComponentUpdate({}, {}, { a: 0 }, {}));
});

it('should not update on derived props', () => {
assert(!shouldComponentUpdate({ derived_test: 0 }, { derived_test: 1 }, {}, {}));
});

it('should update on derived state', () => {
assert(shouldComponentUpdate({}, {}, { derived_test: 0 }, { derived_test: 1 }));
});
});
3 changes: 3 additions & 0 deletions tests/integration/review_app/test_app_df_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,8 @@ def update_graph(rows, selected_rows):
dash_duo.wait_for_element("#waitfor")

dash_duo.wait_for_element("#{}".format(IDS["table"]))
dash_duo.wait_for_element("#pop svg")
dash_duo.wait_for_element("#lifeExp svg")
dash_duo.wait_for_element("#gdpPercap svg")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Slight changes in timing / rendering require the test to be more specific and wait for the graph to be ready


dash_duo.percy_snapshot("rapp002 - loaded")