This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 144
Ensure that components are still in the DOM when they are loading. #740
Merged
+375
−343
Merged
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
8e181d7
Ensure that components are still in the DOM when they are loading.
73db3ca
Define style prop for spinners as object and not bool.
377004b
Fix CSS property names.
a09a508
Merge branch 'dev' into 674-map-uirevision
284c3a3
Update loading component tests.
a90af15
Merge branch 'dev' into 674-map-uirevision
ceff132
Merge branch 'dev' into 674-map-uirevision
6167e15
Merge branch 'dev' into 674-map-uirevision
Marc-Andre-Rivet bfe6d15
Fix test name.
shammamah-zz 8dc4529
Lock circleci python versions.
shammamah-zz 1ead9bc
Merge branch 'dev' into 674-map-uirevision
ef5d193
Merge branch 'dev' into 674-map-uirevision
1cb8da3
Update CHANGELOG.
49fc1ea
Merge branch 'dev' into 674-map-uirevision
alexcjohnson f985ece
revert python version lock on CI
alexcjohnson 01425ff
pyest.ini - mainly to speed up test discovery with `testpaths`
alexcjohnson 6d398a2
extend --pause option to dashdcc fixture
alexcjohnson aa4fce7
fix typo in test_graph_basics that somehow we didn't care about before
alexcjohnson 600a09f
more consistent structure for Loading component
alexcjohnson 386137e
robustify store test
alexcjohnson 22a1975
port loading component tests to dash.testing - without fixing them
alexcjohnson 2bfaa28
update loading component tests for new class usage
alexcjohnson 8bf9fbf
black test_loading_component
alexcjohnson 26c6533
test that children retain identity inside loading components
alexcjohnson a80f0db
Update CHANGELOG.md
alexcjohnson 4fc809a
include computed visibility in the loading/graph test
alexcjohnson fb15aa9
Merge branch '674-map-uirevision' of github.com:plotly/dash-core-comp…
alexcjohnson 2b41ea0
robustify store test_data_lifecycle
alexcjohnson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,27 +49,26 @@ export default class Loading extends Component { | |
type: spinnerType, | ||
} = this.props; | ||
|
||
if (loading_state && loading_state.is_loading) { | ||
const Spinner = getSpinner(spinnerType); | ||
return ( | ||
<Spinner | ||
className={className} | ||
style={style} | ||
status={loading_state} | ||
color={color} | ||
debug={debug} | ||
fullscreen={fullscreen} | ||
/> | ||
); | ||
} | ||
|
||
if ( | ||
type(this.props.children) !== 'Object' || | ||
type(this.props.children) !== 'Function' | ||
) { | ||
return <div className={className}>{this.props.children}</div>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, this part, right? Agreed, it isn't clear to me why this was there. |
||
} | ||
return this.props.children; | ||
const isLoading = loading_state && loading_state.is_loading; | ||
const Spinner = isLoading && getSpinner(spinnerType); | ||
|
||
return ( | ||
<div style={isLoading ? hiddenContainer : {}}> | ||
{this.props.children} | ||
<div style={isLoading ? coveringSpinner : {}}> | ||
{isLoading && ( | ||
<Spinner | ||
className={className} | ||
style={style} | ||
status={loading_state} | ||
color={color} | ||
debug={debug} | ||
fullscreen={fullscreen} | ||
/> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
|
@@ -85,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, | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having this line cuts test discovery time locally from ~10 seconds to <1sec - particularly nice when calling
pytest -k ...
I didn't pay attention to the other lines, just copied from
dash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉