-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3011 from CNFeffery/dev
Fix #3010 Assigning None to exact or shape array properties causes exception
- Loading branch information
Showing
5 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
@plotly/dash-test-components/src/components/ArrayOfExactOrShapeWithNodePropAssignNone.js
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,30 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const ArrayOfExactOrShapeWithNodePropAssignNone = (props) => { | ||
const { id, test_array_of_exact_prop, test_array_of_shape_prop } = props; | ||
|
||
return ( | ||
<div id={id}> | ||
{`length of test_array_of_exact_prop: ${(test_array_of_exact_prop || []).length}, length of test_array_of_shape_prop: ${(test_array_of_shape_prop || []).length}`} | ||
</div> | ||
); | ||
}; | ||
|
||
ArrayOfExactOrShapeWithNodePropAssignNone.propTypes = { | ||
id: PropTypes.string, | ||
test_array_of_exact_prop: PropTypes.arrayOf( | ||
PropTypes.exact({ | ||
label: PropTypes.node, | ||
value: PropTypes.string | ||
}) | ||
), | ||
test_array_of_shape_prop: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
label: PropTypes.node, | ||
value: PropTypes.string | ||
}) | ||
) | ||
}; | ||
|
||
export default ArrayOfExactOrShapeWithNodePropAssignNone; |
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
31 changes: 31 additions & 0 deletions
31
tests/integration/renderer/test_array_of_exact_or_shape_with_node_prop_assign_none.py
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,31 @@ | ||
from dash import Dash, html | ||
|
||
from dash_test_components import ArrayOfExactOrShapeWithNodePropAssignNone | ||
|
||
|
||
def test_aoeoswnpsn001_array_of_exact_or_shape_with_node_prop_assign_none(dash_duo): | ||
app = Dash(__name__) | ||
app.layout = html.Div( | ||
[ | ||
ArrayOfExactOrShapeWithNodePropAssignNone( | ||
id="test-component1", | ||
test_array_of_exact_prop=[{"label": c, "value": c} for c in "abc"], | ||
test_array_of_shape_prop=[{"label": c, "value": c} for c in "abc"], | ||
), | ||
ArrayOfExactOrShapeWithNodePropAssignNone( | ||
id="test-component2", | ||
test_array_of_exact_prop=None, | ||
test_array_of_shape_prop=None, | ||
), | ||
] | ||
) | ||
|
||
dash_duo.start_server(app) | ||
dash_duo.wait_for_text_to_equal( | ||
"#test-component1", | ||
"length of test_array_of_exact_prop: 3, length of test_array_of_shape_prop: 3", | ||
) | ||
dash_duo.wait_for_text_to_equal( | ||
"#test-component2", | ||
"length of test_array_of_exact_prop: 0, length of test_array_of_shape_prop: 0", | ||
) |