From 52b5a368b3b236ab371e833c6aefee291b0d8a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Rivet?= Date: Tue, 26 May 2020 16:44:02 -0400 Subject: [PATCH 01/10] use dash state-machine branch --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f01bb27a0..0f5af10ac 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,7 +25,7 @@ jobs: python -m venv venv || virtualenv venv . venv/bin/activate pip install -r dev-requirements.txt --quiet - git clone --depth 1 git@github.com:plotly/dash.git dash-main + git clone -b state-machine --depth 1 git@github.com:plotly/dash.git dash-main pip install -e ./dash-main[dev,testing] --quiet cd dash-main/dash-renderer && npm ci && npm run build && pip install -e . && cd ./../.. @@ -107,7 +107,7 @@ jobs: python -m venv venv || virtualenv venv . venv/bin/activate pip install -r dev-requirements.txt --quiet - git clone --depth 1 git@github.com:plotly/dash.git dash-main + git clone -b state-machine --depth 1 git@github.com:plotly/dash.git dash-main pip install -e ./dash-main[dev] --quiet - run: @@ -213,7 +213,7 @@ jobs: name: Install dependencies (dash) command: | . venv/bin/activate - git clone --depth 1 git@github.com:plotly/dash.git dash-main + git clone -b state-machine --depth 1 git@github.com:plotly/dash.git dash-main pip install -e ./dash-main[dev,testing] --quiet cd dash-main/dash-renderer && npm ci && npm run build && pip install -e . && cd ../.. From 1defea21ea3d36ebc759675f000b412396482fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Rivet?= Date: Wed, 27 May 2020 16:34:05 -0400 Subject: [PATCH 02/10] noise From 36885d7cdec742530e689216f15e5c35137308d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Rivet?= Date: Wed, 27 May 2020 17:23:40 -0400 Subject: [PATCH 03/10] 3.7.6 --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0f5af10ac..c11a3668c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ version: 2 jobs: "server-test": docker: - - image: circleci/python:3.7-node-browsers + - image: circleci/python:3.7.6-node-browsers - image: cypress/base:10 steps: From bf0d25ce3699939e3cd3979589364f24a0a5763a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Rivet?= Date: Wed, 27 May 2020 17:57:14 -0400 Subject: [PATCH 04/10] remove cache --- .circleci/config.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c11a3668c..770d0e213 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,16 +8,9 @@ jobs: steps: - checkout - - restore_cache: - key: dep-{{ .Branch }}-{{ checksum "package-lock.json" }}-{{ checksum "package.json" }}-{{ checksum ".circleci/config.yml" }} - run: name: Install npm packages command: npm ci - - save_cache: - key: dep-{{ .Branch }}-{{ checksum "package-lock.json" }}-{{ checksum "package.json" }}-{{ checksum ".circleci/config.yml" }} - paths: - - node_modules - - run: name: Install requirements command: | From dc01001ebb4b405bff9a44398fe12abb293d3085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Rivet?= Date: Fri, 29 May 2020 09:43:18 -0400 Subject: [PATCH 05/10] re-render on previously missing props --- CHANGELOG.md | 4 ++++ src/dash-table/components/Table/index.tsx | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f78d2923..8ec919b0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [Unreleased] +### 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 diff --git a/src/dash-table/components/Table/index.tsx b/src/dash-table/components/Table/index.tsx index d9eeecf52..949f287a6 100644 --- a/src/dash-table/components/Table/index.tsx +++ b/src/dash-table/components/Table/index.tsx @@ -97,7 +97,7 @@ export default class Table extends Component !DERIVED_REGEX.test(key) && props[key] !== nextProps[key], - R.keysIn(props) + R.keysIn({ ...props, ...nextProps }) ) || !isEqual(state, nextState); } From 7b46e052cf5555dd3f22fb1017f6dbfe6cd94be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Rivet?= Date: Fri, 29 May 2020 10:08:35 -0400 Subject: [PATCH 06/10] make sure the graphs are visible before taking snapshot --- tests/integration/review_app/test_app_df_graph.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/integration/review_app/test_app_df_graph.py b/tests/integration/review_app/test_app_df_graph.py index 60dfecd9a..d2c1a3ecf 100644 --- a/tests/integration/review_app/test_app_df_graph.py +++ b/tests/integration/review_app/test_app_df_graph.py @@ -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") dash_duo.percy_snapshot("rapp002 - loaded") From 70a038d49391cbb8f11fddee9d766b4b4de010d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Rivet?= Date: Fri, 5 Jun 2020 10:13:15 -0400 Subject: [PATCH 07/10] noise From 74d51ee3b645d4ad0ebfaba8ae4a1088b4711ead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Rivet?= Date: Wed, 10 Jun 2020 16:57:29 -0400 Subject: [PATCH 08/10] noise From 9069a19077f2854c6cc939dcc988d282b1e75d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Rivet?= Date: Mon, 15 Jun 2020 17:37:33 -0400 Subject: [PATCH 09/10] Update config.yml --- .circleci/config.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a218d6225..fb7daa154 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,9 +8,16 @@ jobs: steps: - checkout + - restore_cache: + key: dep-{{ .Branch }}-{{ checksum "package-lock.json" }}-{{ checksum "package.json" }}-{{ checksum ".circleci/config.yml" }} - run: name: Install npm packages command: npm ci + - save_cache: + key: dep-{{ .Branch }}-{{ checksum "package-lock.json" }}-{{ checksum "package.json" }}-{{ checksum ".circleci/config.yml" }} + paths: + - node_modules + - run: name: Install requirements command: | @@ -18,7 +25,7 @@ jobs: python -m venv venv || virtualenv venv . venv/bin/activate pip install -r dev-requirements.txt --quiet - git clone -b state-machine --depth 1 git@github.com:plotly/dash.git dash-main + git clone --depth 1 git@github.com:plotly/dash.git dash-main pip install -e ./dash-main[dev,testing] --quiet cd dash-main/dash-renderer && npm ci && npm run build && pip install -e . && cd ./../.. @@ -100,8 +107,7 @@ jobs: python -m venv venv || virtualenv venv . venv/bin/activate pip install -r dev-requirements.txt --quiet - git clone -b state-machine --depth 1 git@github.com:plotly/dash.git dash-main - pip install -e ./dash-main[dev] --quiet + pip install --progress-bar off -e git+https://github.com/plotly/dash.git@dev#egg=dash[dev,testing] - run: name: Run tests @@ -207,7 +213,7 @@ jobs: name: Install dependencies (dash) command: | . venv/bin/activate - git clone -b state-machine --depth 1 git@github.com:plotly/dash.git dash-main + git clone --depth 1 git@github.com:plotly/dash.git dash-main pip install -e ./dash-main[dev,testing] --quiet cd dash-main/dash-renderer && npm ci && npm run build && pip install -e . && cd ../.. From 8849e85932ba6b4f3d739a3a6934fbb852d90115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Rivet?= Date: Wed, 17 Jun 2020 12:03:12 -0400 Subject: [PATCH 10/10] unit test table shouldComponentUpdate condition --- src/dash-table/components/Table/index.tsx | 10 +++---- .../components/Table/shouldComponentUpdate.ts | 14 ++++++++++ tests/cypress/tests/unit/table_update_test.ts | 27 +++++++++++++++++++ 3 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 src/dash-table/components/Table/shouldComponentUpdate.ts create mode 100644 tests/cypress/tests/unit/table_update_test.ts diff --git a/src/dash-table/components/Table/index.tsx b/src/dash-table/components/Table/index.tsx index f356a3bfa..86d0a76fd 100644 --- a/src/dash-table/components/Table/index.tsx +++ b/src/dash-table/components/Table/index.tsx @@ -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 { constructor(props: SanitizedAndDerivedProps) { @@ -94,10 +92,7 @@ export default class Table extends Component - !DERIVED_REGEX.test(key) && props[key] !== nextProps[key], - R.keysIn({ ...props, ...nextProps }) - ) || !isEqual(state, nextState); + return shouldComponentUpdate(props, nextProps, state, nextState); } render() { @@ -159,3 +154,4 @@ export default class Table extends Component R.any( + key => !DERIVED_REGEX.test(key) && props[key] !== nextProps[key], + R.keysIn({ ...props, ...nextProps }) +) || !isEqual(state, nextState); \ No newline at end of file diff --git a/tests/cypress/tests/unit/table_update_test.ts b/tests/cypress/tests/unit/table_update_test.ts new file mode 100644 index 000000000..34de59fb5 --- /dev/null +++ b/tests/cypress/tests/unit/table_update_test.ts @@ -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 })); + }); + + 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 })); + }); +});