From 8e181d7722a48528b850c3280237020cb2e3cbdb Mon Sep 17 00:00:00 2001 From: Shammamah Hossain Date: Wed, 22 Jan 2020 14:21:44 -0500 Subject: [PATCH 01/20] Ensure that components are still in the DOM when they are loading. --- src/components/Loading.react.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/components/Loading.react.js b/src/components/Loading.react.js index 2077fbb9e..7a29f2784 100644 --- a/src/components/Loading.react.js +++ b/src/components/Loading.react.js @@ -40,14 +40,27 @@ export default class Loading extends Component { if (loading_state && loading_state.is_loading) { const Spinner = getSpinner(spinnerType); return ( - +
+ {this.props.children} + +
); } From 73db3ca5132632c2947e54c20c59cbee73c3adbd Mon Sep 17 00:00:00 2001 From: Shammamah Hossain Date: Wed, 22 Jan 2020 14:31:06 -0500 Subject: [PATCH 02/20] Define style prop for spinners as object and not bool. --- src/fragments/Loading/spinners/CircleSpinner.jsx | 2 +- src/fragments/Loading/spinners/CubeSpinner.jsx | 2 +- src/fragments/Loading/spinners/DefaultSpinner.jsx | 2 +- src/fragments/Loading/spinners/DotSpinner.jsx | 2 +- src/fragments/Loading/spinners/GraphSpinner.jsx | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/fragments/Loading/spinners/CircleSpinner.jsx b/src/fragments/Loading/spinners/CircleSpinner.jsx index c7d1369a3..ab53798ea 100644 --- a/src/fragments/Loading/spinners/CircleSpinner.jsx +++ b/src/fragments/Loading/spinners/CircleSpinner.jsx @@ -191,7 +191,7 @@ CircleSpinner.propTypes = { color: PropTypes.string, className: PropTypes.string, fullscreen: PropTypes.bool, - style: PropTypes.bool, + style: PropTypes.object, debug: PropTypes.bool, }; diff --git a/src/fragments/Loading/spinners/CubeSpinner.jsx b/src/fragments/Loading/spinners/CubeSpinner.jsx index 73dd71c79..5736c321f 100644 --- a/src/fragments/Loading/spinners/CubeSpinner.jsx +++ b/src/fragments/Loading/spinners/CubeSpinner.jsx @@ -193,7 +193,7 @@ CubeSpinner.propTypes = { color: PropTypes.string, className: PropTypes.string, fullscreen: PropTypes.bool, - style: PropTypes.bool, + style: PropTypes.object, debug: PropTypes.bool, }; diff --git a/src/fragments/Loading/spinners/DefaultSpinner.jsx b/src/fragments/Loading/spinners/DefaultSpinner.jsx index 959904682..5770b9142 100644 --- a/src/fragments/Loading/spinners/DefaultSpinner.jsx +++ b/src/fragments/Loading/spinners/DefaultSpinner.jsx @@ -116,7 +116,7 @@ DefaultSpinner.propTypes = { color: PropTypes.string, className: PropTypes.string, fullscreen: PropTypes.bool, - style: PropTypes.bool, + style: PropTypes.object, debug: PropTypes.bool, }; diff --git a/src/fragments/Loading/spinners/DotSpinner.jsx b/src/fragments/Loading/spinners/DotSpinner.jsx index 7f41a1264..6cf81159d 100644 --- a/src/fragments/Loading/spinners/DotSpinner.jsx +++ b/src/fragments/Loading/spinners/DotSpinner.jsx @@ -95,7 +95,7 @@ DotSpinner.propTypes = { color: PropTypes.string, className: PropTypes.string, fullscreen: PropTypes.bool, - style: PropTypes.bool, + style: PropTypes.object, debug: PropTypes.bool, }; diff --git a/src/fragments/Loading/spinners/GraphSpinner.jsx b/src/fragments/Loading/spinners/GraphSpinner.jsx index 5cc4ac5e2..50d32c462 100644 --- a/src/fragments/Loading/spinners/GraphSpinner.jsx +++ b/src/fragments/Loading/spinners/GraphSpinner.jsx @@ -332,7 +332,7 @@ GraphSpinner.propTypes = { color: PropTypes.string, className: PropTypes.string, fullscreen: PropTypes.bool, - style: PropTypes.bool, + style: PropTypes.object, debug: PropTypes.bool, }; From 377004bb9d83186be17fa23db0d3ae5051d3fb67 Mon Sep 17 00:00:00 2001 From: Shammamah Hossain Date: Wed, 22 Jan 2020 14:31:23 -0500 Subject: [PATCH 03/20] Fix CSS property names. --- src/components/Loading.react.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Loading.react.js b/src/components/Loading.react.js index 7a29f2784..06d5810c4 100644 --- a/src/components/Loading.react.js +++ b/src/components/Loading.react.js @@ -51,8 +51,8 @@ export default class Loading extends Component { height: '100%', width: '100%', display: 'flex', - 'justify-content': 'center', - 'align-items': 'center', + justifyContent: 'center', + alignItems: 'center', ...style, }} status={loading_state} From 284c3a3dafc7b5ce86d6d8c096cfde609afab66b Mon Sep 17 00:00:00 2001 From: Shammamah Hossain Date: Thu, 23 Jan 2020 14:06:08 -0500 Subject: [PATCH 04/20] Update loading component tests. --- tests/unit/Loading.test.js | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/tests/unit/Loading.test.js b/tests/unit/Loading.test.js index d9d716e10..3e3913d84 100644 --- a/tests/unit/Loading.test.js +++ b/tests/unit/Loading.test.js @@ -14,7 +14,12 @@ test('Loading renders', () => { ); - expect(loading.html()).toMatchSnapshot('Loading with is_loading=true'); + expect( + loading + .find('.dash-spinner') + .parent() + .html() + ).toMatchSnapshot('Loading with is_loading=true'); }); test('Loading renders without loading_state', () => { const loading = render( @@ -49,7 +54,12 @@ test('Loading renders without prop_name', () => { ); - expect(loading.html()).toMatchSnapshot('Loading with is_loading=true'); + expect( + loading + .find('.dash-spinner') + .parent() + .html() + ).toMatchSnapshot('Loading with is_loading=true'); }); test('Loading renders without loading_state.component_name', () => { const statusMock = { @@ -62,7 +72,12 @@ test('Loading renders without loading_state.component_name', () => { ); - expect(loading.html()).toMatchSnapshot('Loading with is_loading=true'); + expect( + loading + .find('.dash-spinner') + .parent() + .html() + ).toMatchSnapshot('Loading with is_loading=true'); }); test('Loading renders with multiple children', () => { const statusMock = { @@ -78,7 +93,12 @@ test('Loading renders with multiple children', () => { ); - expect(loading.html()).toMatchSnapshot('Loading with is_loading=true'); + expect( + loading + .find('.dash-spinner') + .parent() + .html() + ).toMatchSnapshot('Loading with is_loading=true'); }); test("Loading checks all it's children for a loading_state", () => { From bfe6d15be89cfb9dee55a53671316875624651dd Mon Sep 17 00:00:00 2001 From: Shammamah Hossain Date: Tue, 3 Mar 2020 11:06:15 -0500 Subject: [PATCH 05/20] Fix test name. --- tests/integration/graph/test_graph_basics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/graph/test_graph_basics.py b/tests/integration/graph/test_graph_basics.py index 55d361e18..873c14854 100644 --- a/tests/integration/graph/test_graph_basics.py +++ b/tests/integration/graph/test_graph_basics.py @@ -93,7 +93,7 @@ def selected_df_figure(selection): @pytest.mark.DCC672 -def test_grbs002_graph_wrapped_in_loading_component_does_not_fail(dash_dcc): +def test_grbs003_graph_wrapped_in_loading_component_does_not_fail(dash_dcc): app = dash.Dash(__name__, suppress_callback_exceptions=True) app.layout = html.Div([ html.H1('subplot issue'), From 8dc4529e46d9c0e9245467835412cc4d335427c4 Mon Sep 17 00:00:00 2001 From: Shammamah Hossain Date: Tue, 3 Mar 2020 12:05:27 -0500 Subject: [PATCH 06/20] Lock circleci python versions. --- .circleci/config.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2ece53603..111d0b338 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,7 +9,7 @@ jobs: lint-unit-37: &lint-unit working_directory: ~/project docker: - - image: circleci/python:3.7-stretch-node-browsers + - image: circleci/python:3.7.5-stretch-node-browsers environment: PYTHON_VERSION: py37 steps: @@ -44,21 +44,21 @@ jobs: lint-unit-36: <<: *lint-unit docker: - - image: circleci/python:3.6-stretch-node-browsers + - image: circleci/python:3.6.9-stretch-node-browsers environment: PYTHON_VERSION: py36 lint-unit-27: <<: *lint-unit docker: - - image: circleci/python:2.7-stretch-node-browsers + - image: circleci/python:2.7.16-stretch-node-browsers environment: PYTHON_VERSION: py27 build-dash-37: &build-dash working_directory: ~/project docker: - - image: circleci/python:3.7-stretch-node-browsers + - image: circleci/python:3.7.5-stretch-node-browsers environment: PYTHON_VERSION: py37 steps: @@ -99,21 +99,21 @@ jobs: build-dash-36: <<: *build-dash docker: - - image: circleci/python:3.6-stretch-node-browsers + - image: circleci/python:3.6.9-stretch-node-browsers environment: PYTHON_VERSION: py36 build-dash-27: <<: *build-dash docker: - - image: circleci/python:2.7-stretch-node-browsers + - image: circleci/python:2.7.16-stretch-node-browsers environment: PYTHON_VERSION: py27 test-37: &test working_directory: ~/project docker: - - image: circleci/python:3.7-stretch-node-browsers + - image: circleci/python:3.7.5-stretch-node-browsers environment: PYTHON_VERSION: py37 PERCY_PARALLEL_TOTAL: -1 @@ -145,7 +145,7 @@ jobs: test-36: <<: *test docker: - - image: circleci/python:3.6-stretch-node-browsers + - image: circleci/python:3.6.9-stretch-node-browsers environment: PYTHON_VERSION: py36 PERCY_ENABLE: 0 @@ -153,7 +153,7 @@ jobs: test-27: <<: *test docker: - - image: circleci/python:2.7-stretch-node-browsers + - image: circleci/python:2.7.16-stretch-node-browsers environment: PYTHON_VERSION: py27 PERCY_ENABLE: 0 @@ -161,7 +161,7 @@ jobs: test-legacy-37: &test-legacy working_directory: ~/project docker: - - image: circleci/python:3.7-stretch-node-browsers + - image: circleci/python:3.7.5-stretch-node-browsers environment: PYTHON_VERSION: py37 PERCY_PARALLEL_TOTAL: -1 @@ -195,14 +195,14 @@ jobs: test-legacy-36: <<: *test-legacy docker: - - image: circleci/python:3.6-stretch-node-browsers + - image: circleci/python:3.6.9-stretch-node-browsers environment: PYTHON_VERSION: py36 PERCY_ENABLE: 0 test-legacy-27: <<: *test-legacy docker: - - image: circleci/python:2.7-stretch-node-browsers + - image: circleci/python:2.7.16-stretch-node-browsers environment: PYTHON_VERSION: py27 PERCY_ENABLE: 0 From 1cb8da34cbc47b2143a40b91a6e0104acef389bd Mon Sep 17 00:00:00 2001 From: Shammamah Hossain Date: Tue, 10 Mar 2020 15:39:08 -0400 Subject: [PATCH 07/20] Update CHANGELOG. --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c48cd564e..0d8218c8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,10 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Changed - [#766](https://github.com/plotly/dash-core-components/pull/766) Update from React 16.8.6 to 16.13.0 +- [#740](https://github.com/plotly/dash-core-components/pull/740) Keep components that are loading in the DOM, but not visible, as opposed to removing them entirely +### Fixed +- [#740](https://github.com/plotly/dash-core-components/pull/740) Fixed bug in which mapbox `uirevision` was not behaving when inside a `dcc.Loading` component ## [1.8.1] -2020-02-27 ### Added From f985ece3f27b98d7cba74f91b382a1f4acd03f6e Mon Sep 17 00:00:00 2001 From: alexcjohnson Date: Thu, 9 Apr 2020 10:42:29 -0400 Subject: [PATCH 08/20] revert python version lock on CI --- .circleci/config.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 32007c86f..8ae9a3857 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,7 +9,7 @@ jobs: lint-unit-37: &lint-unit working_directory: ~/project docker: - - image: circleci/python:3.7.5-stretch-node-browsers + - image: circleci/python:3.7-stretch-node-browsers environment: PYTHON_VERSION: py37 steps: @@ -42,21 +42,21 @@ jobs: lint-unit-36: <<: *lint-unit docker: - - image: circleci/python:3.6.9-stretch-node-browsers + - image: circleci/python:3.6-stretch-node-browsers environment: PYTHON_VERSION: py36 lint-unit-27: <<: *lint-unit docker: - - image: circleci/python:2.7.16-stretch-node-browsers + - image: circleci/python:2.7-stretch-node-browsers environment: PYTHON_VERSION: py27 build-dash-37: &build-dash working_directory: ~/project docker: - - image: circleci/python:3.7.5-stretch-node-browsers + - image: circleci/python:3.7-stretch-node-browsers environment: PYTHON_VERSION: py37 steps: @@ -97,21 +97,21 @@ jobs: build-dash-36: <<: *build-dash docker: - - image: circleci/python:3.6.9-stretch-node-browsers + - image: circleci/python:3.6-stretch-node-browsers environment: PYTHON_VERSION: py36 build-dash-27: <<: *build-dash docker: - - image: circleci/python:2.7.16-stretch-node-browsers + - image: circleci/python:2.7-stretch-node-browsers environment: PYTHON_VERSION: py27 test-37: &test working_directory: ~/project docker: - - image: circleci/python:3.7.5-stretch-node-browsers + - image: circleci/python:3.7-stretch-node-browsers environment: PYTHON_VERSION: py37 PERCY_PARALLEL_TOTAL: -1 @@ -143,7 +143,7 @@ jobs: test-36: <<: *test docker: - - image: circleci/python:3.6.9-stretch-node-browsers + - image: circleci/python:3.6-stretch-node-browsers environment: PYTHON_VERSION: py36 PERCY_ENABLE: 0 @@ -151,7 +151,7 @@ jobs: test-27: <<: *test docker: - - image: circleci/python:2.7.16-stretch-node-browsers + - image: circleci/python:2.7-stretch-node-browsers environment: PYTHON_VERSION: py27 PERCY_ENABLE: 0 @@ -159,7 +159,7 @@ jobs: test-legacy-37: &test-legacy working_directory: ~/project docker: - - image: circleci/python:3.7.5-stretch-node-browsers + - image: circleci/python:3.7-stretch-node-browsers environment: PYTHON_VERSION: py37 PERCY_PARALLEL_TOTAL: -1 @@ -193,14 +193,14 @@ jobs: test-legacy-36: <<: *test-legacy docker: - - image: circleci/python:3.6.9-stretch-node-browsers + - image: circleci/python:3.6-stretch-node-browsers environment: PYTHON_VERSION: py36 PERCY_ENABLE: 0 test-legacy-27: <<: *test-legacy docker: - - image: circleci/python:2.7.16-stretch-node-browsers + - image: circleci/python:2.7-stretch-node-browsers environment: PYTHON_VERSION: py27 PERCY_ENABLE: 0 From 01425ff5a7e2d68b6a20d5dbc4dcc3f791fd57f8 Mon Sep 17 00:00:00 2001 From: alexcjohnson Date: Thu, 9 Apr 2020 11:33:05 -0400 Subject: [PATCH 09/20] pyest.ini - mainly to speed up test discovery with `testpaths` --- pytest.ini | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 pytest.ini diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 000000000..b6302a609 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,5 @@ +[pytest] +testpaths = tests/ +addopts = -rsxX -vv +log_format = %(asctime)s | %(levelname)s | %(name)s:%(lineno)d | %(message)s +log_cli_level = ERROR From 6d398a225764b836f7bc62661e5eb7795005e44d Mon Sep 17 00:00:00 2001 From: alexcjohnson Date: Thu, 9 Apr 2020 11:42:20 -0400 Subject: [PATCH 10/20] extend --pause option to dashdcc fixture --- tests/conftest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/conftest.py b/tests/conftest.py index 34b124ae1..516aed669 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -30,5 +30,6 @@ def dash_dcc(request, dash_thread_server, tmpdir): download_path=tmpdir.mkdir("download").strpath, percy_assets_root=request.config.getoption("percy_assets"), percy_finalize=request.config.getoption("nopercyfinalize"), + pause=request.config.getoption("pause"), ) as dc: yield dc From aa4fce7b739de4c91fbae9e746c0b06883dd8569 Mon Sep 17 00:00:00 2001 From: alexcjohnson Date: Thu, 9 Apr 2020 11:43:34 -0400 Subject: [PATCH 11/20] fix typo in test_graph_basics that somehow we didn't care about before --- tests/integration/graph/test_graph_basics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/graph/test_graph_basics.py b/tests/integration/graph/test_graph_basics.py index 873c14854..aac21da7f 100644 --- a/tests/integration/graph/test_graph_basics.py +++ b/tests/integration/graph/test_graph_basics.py @@ -101,7 +101,7 @@ def test_grbs003_graph_wrapped_in_loading_component_does_not_fail(dash_dcc): dcc.Loading(id="page-content") ]) - @app.callback(Output('page-content', 'children'), [Input('url', 'value')]) + @app.callback(Output('page-content', 'children'), [Input('url', 'pathname')]) def render_page(url): return [ dcc.Dropdown( From 600a09f5ddd01ec7f3d987063602de794822f912 Mon Sep 17 00:00:00 2001 From: alexcjohnson Date: Thu, 9 Apr 2020 11:45:31 -0400 Subject: [PATCH 12/20] more consistent structure for Loading component --- src/components/Loading.react.js | 78 +++++++++---------- tests/unit/Loading.test.js | 4 +- tests/unit/__snapshots__/Loading.test.js.snap | 2 +- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/components/Loading.react.js b/src/components/Loading.react.js index 06d5810c4..42e560843 100644 --- a/src/components/Loading.react.js +++ b/src/components/Loading.react.js @@ -5,7 +5,6 @@ import DefaultSpinner from '../fragments/Loading/spinners/DefaultSpinner.jsx'; import CubeSpinner from '../fragments/Loading/spinners/CubeSpinner.jsx'; import CircleSpinner from '../fragments/Loading/spinners/CircleSpinner.jsx'; import DotSpinner from '../fragments/Loading/spinners/DotSpinner.jsx'; -import {type} from 'ramda'; function getSpinner(spinnerType) { switch (spinnerType) { @@ -22,6 +21,19 @@ function getSpinner(spinnerType) { } } +const hiddenContainer = {visibility: 'hidden', position: 'relative'}; + +const coveringSpinner = { + visibility: 'visible', + position: 'absolute', + top: '0', + height: '100%', + width: '100%', + display: 'flex', + justifyContent: 'center', + alignItems: 'center', +}; + /** * A Loading component that wraps any other component and displays a spinner until the wrapped component has rendered. */ @@ -37,40 +49,26 @@ export default class Loading extends Component { type: spinnerType, } = this.props; - if (loading_state && loading_state.is_loading) { - const Spinner = getSpinner(spinnerType); - return ( -
- {this.props.children} - + const isLoading = loading_state && loading_state.is_loading; + const Spinner = isLoading && getSpinner(spinnerType); + + return ( +
+ {this.props.children} +
+ {isLoading && ( + + )}
- ); - } - - if ( - type(this.props.children) !== 'Object' || - type(this.props.children) !== 'Function' - ) { - return
{this.props.children}
; - } - return this.props.children; +
+ ); } } @@ -98,27 +96,29 @@ Loading.propTypes = { ]), /** - * Property that determines which spinner to show - one of 'graph', 'cube', 'circle', 'dot', or 'default'. + * Property that determines which spinner to show + * one of 'graph', 'cube', 'circle', 'dot', or 'default'. */ type: PropTypes.oneOf(['graph', 'cube', 'circle', 'dot', 'default']), /** - * Boolean that determines if the loading spinner will be displayed full-screen or not + * Boolean that makes the spinner display full-screen */ fullscreen: PropTypes.bool, /** - * Boolean that determines if the loading spinner will display the status.prop_name and component_name + * If true, the spinner will display the component_name and prop_name + * while loading */ debug: PropTypes.bool, /** - * Additional CSS class for the root DOM node + * Additional CSS class for the spinner root DOM node */ className: PropTypes.string, /** - * Additional CSS styling for the root DOM node + * Additional CSS styling for the spinner root DOM node */ style: PropTypes.object, diff --git a/tests/unit/Loading.test.js b/tests/unit/Loading.test.js index 3e3913d84..9442376d1 100644 --- a/tests/unit/Loading.test.js +++ b/tests/unit/Loading.test.js @@ -28,7 +28,7 @@ test('Loading renders without loading_state', () => { ); - expect(loading.html()).toEqual('
Loading is done!
'); + expect(loading.html()).toEqual('
Loading is done!
'); }); test('Loading renders without loading_state.is_loading', () => { const statusMock = { @@ -41,7 +41,7 @@ test('Loading renders without loading_state.is_loading', () => { ); - expect(loading.html()).toEqual('
Loading is done!
'); + expect(loading.html()).toEqual('
Loading is done!
'); }); test('Loading renders without prop_name', () => { const statusMock = { diff --git a/tests/unit/__snapshots__/Loading.test.js.snap b/tests/unit/__snapshots__/Loading.test.js.snap index 29d3a8c2b..84f1bea22 100644 --- a/tests/unit/__snapshots__/Loading.test.js.snap +++ b/tests/unit/__snapshots__/Loading.test.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Loading checks all it's children for a loading_state: Loading spinner for children 1`] = `"
Child 1
Child 2
Child 3
"`; +exports[`Loading checks all it's children for a loading_state: Loading spinner for children 1`] = `"
Child 1
Child 2
Child 3
"`; exports[`Loading renders with multiple children: Loading with is_loading=true 1`] = ` "